mirror of
https://github.com/ZDoom/fluidsynth.git
synced 2024-11-10 06:51:54 +00:00
add a unit test for manually unregistering via fluid_event_unregistering()
currently results in a double free
This commit is contained in:
parent
3dcb7d3b92
commit
34912586f0
2 changed files with 30 additions and 0 deletions
|
@ -13,6 +13,7 @@ ADD_FLUID_TEST(test_sample_cache)
|
|||
ADD_FLUID_TEST(test_sfont_loading)
|
||||
ADD_FLUID_TEST(test_sample_rate_change)
|
||||
ADD_FLUID_TEST(test_preset_sample_loading)
|
||||
ADD_FLUID_TEST(test_seqbind_unregister)
|
||||
|
||||
if ( LIBSNDFILE_HASVORBIS )
|
||||
ADD_FLUID_TEST(test_sf3_sfont_loading)
|
||||
|
|
29
test/test_seqbind_unregister.c
Normal file
29
test/test_seqbind_unregister.c
Normal file
|
@ -0,0 +1,29 @@
|
|||
|
||||
#include "test.h"
|
||||
#include "fluidsynth.h" // use local fluidsynth header
|
||||
|
||||
// simple test to ensure that manually unregistering and deleting the internal fluid_seqbind_t works without crashing
|
||||
int main()
|
||||
{
|
||||
fluid_settings_t* settings = new_fluid_settings();
|
||||
fluid_synth_t* synth = new_fluid_synth(settings);
|
||||
fluid_sequencer_t* seq = new_fluid_sequencer2(0 /*i.e. use sample timer*/);
|
||||
|
||||
// silently creates a fluid_seqbind_t
|
||||
int seqid = fluid_sequencer_register_fluidsynth(seq, synth);
|
||||
|
||||
fluid_event_t* evt = new_fluid_event();
|
||||
fluid_event_set_source(evt, -1);
|
||||
fluid_event_set_dest(evt, seqid);
|
||||
|
||||
// manually free the fluid_seqbind_t
|
||||
fluid_event_unregistering(evt);
|
||||
fluid_sequencer_send_now(seq, evt);
|
||||
|
||||
// client should be removed, deleting the seq should not free the struct again
|
||||
delete_fluid_sequencer(seq);
|
||||
delete_fluid_synth(synth);
|
||||
delete_fluid_settings(settings);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
Loading…
Reference in a new issue