Mixer: Fix invalid read in module picker.

This commit is contained in:
Jonathan Moore Liles 2010-01-17 23:27:51 -06:00
parent fb9aac8178
commit 26a0ef1a27
2 changed files with 19 additions and 11 deletions

View File

@ -322,9 +322,9 @@ Module::pick_module ( void )
menu->type( Fl_Menu_Button::POPUP3 ); menu->type( Fl_Menu_Button::POPUP3 );
// menu->add( "JACK", 0, 0, (void*)1 ); // menu->add( "JACK", 0, 0, (void*)1 );
menu->add( "Gain", 0, 0, (void*)2 ); menu->add( "Gain", 0, 0, new unsigned long(-2) );
menu->add( "Meter", 0, 0, (void*)3 ); menu->add( "Meter", 0, 0, new unsigned long(-3) );
menu->add( "Mono Pan", 0, 0, (void*)4 ); menu->add( "Mono Pan", 0, 0, new unsigned long(-4) );
Plugin_Module::add_plugins_to_menu( menu ); Plugin_Module::add_plugins_to_menu( menu );
@ -338,22 +338,30 @@ Module::pick_module ( void )
if ( ! v ) if ( ! v )
return NULL; return NULL;
switch ( (int)v ) unsigned long id = *((unsigned long *)v);
switch ( id )
{ {
case 1: case -1:
return new JACK_Module(); return new JACK_Module();
case 2: case -2:
return new Gain_Module(); return new Gain_Module();
case 3: case -3:
return new Meter_Module(); return new Meter_Module();
case 4: case -4:
return new Mono_Pan_Module(); return new Mono_Pan_Module();
} }
Plugin_Module::Plugin_Info *pi = (Plugin_Module::Plugin_Info*)v; /* Plugin_Module::Plugin_Info *pi = (Plugin_Module::Plugin_Info*)v; */
Plugin_Module *m = new Plugin_Module(); Plugin_Module *m = new Plugin_Module();
m->load( pi->id ); m->load( id );
for ( const Fl_Menu_Item *mi = menu->menu(); mi->label(); ++mi )
{
if ( mi->user_data() )
delete mi->user_data();
}
return m; return m;
} }

View File

@ -117,7 +117,7 @@ Plugin_Module::add_plugins_to_menu ( Fl_Menu_Button *menu )
{ {
snprintf( path, sizeof( path ), "%s/%s", "Plugin", pi->path ); snprintf( path, sizeof( path ), "%s/%s", "Plugin", pi->path );
menu->add(path, 0, NULL, pi, 0 ); menu->add(path, 0, NULL, new unsigned long( pi->id ), 0 );
} }
delete[] pia; delete[] pia;