In an out of memory situation, fluid_synth_t::voice and fluid_synth_t::channel may not be fully initialized, causing a NULL dereference and heap corruption in delete_fluid_synth().
fluid_zone_check_linked_mod() is prepared to be called from API functions
fluid_voice_add_mod(), fluid_synth_add_default_mod().
The intend when calling these API is:
1) add a complex modulator as well a simple modulator.
2) keeping input parameter 'mod' list intact (i.e
any modulators shouldn't removed).
The changes are:
- fluid_zone_check_linked_mod() renamed fluid_list_check_linked_mod().
- fluid_zone_copy_linked_mod() renamed fluid_list_copy_linked_mod().
- Calling fluid_list_copy_linked_mod() is integrated in
fluid_list_check_linked_mod(). Now fluid_list_check_linked_mod()
have the possibility:
1) to check only the input list_mod (if linked_mod is NULL).
2) if linked_mod is not NULL, the function clones linked modulators from
lis_mod to linked_mod list.
-unit test test_modulator_links.c is updated with
fluid_zone_check_linked_mod() remamed to fluid_list_check_linked_mod() and
linked_mod parameter to NULL. The behaviour is the same.
- make use of fluid_dump_modulator() in fluid_mod.c
- make use of string literal for printf.
- allow test_fluid_zone_check_mod to be executed with no arguments.
- use of TEST_SUCCESS macro for each test.
- fix minor comments typos.
- When removing modulators in list_mod list, all linked modulators
must be removed regardless they are valid or invalid modulators.
This commit is just a simplification, fluid_zone_check_remove_mod()
behaves as before.
- These checks are moved from soundfont loader to fluid_mod_check_sources().
This ensure these checks will also done when adding modulators by
calling the API functions fluid_voice_add_mod() or
fluid_synth_add_default_mod().
- the variable names are using zero-based indices (eg, mod0,mod1,..)
(instead of 1 based indices).
- this naming is coherent with indices displayed on output which are
zero-based:
Example of output message:
fluidsynth: warning: invalid destination test zone with linked modulators/mod1
This message says that mod1 (i.e modulator at index 1 in the list) is
an invalid destination.
- fluid_voice.c:1856:37: warning: Assigned value is garbage or undefined
min_val *= link_min_max[j].min;
- Add a comment to explain that link_min_max[j].min is still a valid value.
- Clang-tidy complaint should be ignored here.