Closed Xrayez closed 3 years ago
There seems to be an easy fix and I'd fix this myself, but I've noticed another potential bug which I'm not sure about:
The method says note_off()
, but implementation uses tsf_note_on()
.
Also, I'd suggest replacing these type of checks:
into:
ERR_FAIL_NULL_MSG(mTsf, "MidiFile is not loaded");
// or with return value:
ERR_FAIL_NULL_V_MSG(mTsf, 0.0, "MidiFile is not loaded");
Unless there's a use case where mTsf
is expected to be nullptr
.
CC @filipworksdev
Thanks for spotting that! It calls tsf_note_on(mTsf, inPresetIndex, inKey, 0.0);
with a null mTsf
CRASH. Fixed it on my end.
mTsf is the soundfont so it actually crashes because I didn't load the SoundFont.
About the error I have no opinion. It makes sense to not be an error if you have no SoundFont loaded and simply not do anything. Without a SoundFont, MidiPlayer is completely useless lol.
Regarding note_off calling tsf_note_on
there is actually a note off you can replace that line with tsf_note_off(mTsf, inPresetIndex, inKey);
I inherited some of that code and I think it might simply be an honest copy paste error from note_on above.
Damn this fuzzer is good though! Be careful the fuzzer seems to love abusing set_data
in the MidiFile
which will cause crashes. These crashes are expected if you directly manipulate byte data. Unforunately I cannot disable setters because the properties also stop working internally and there is no good way to check if data is valid.
About the error I have no opinion. It makes sense to not be an error if you have no SoundFont loaded and simply not do anything. Without a SoundFont, MidiPlayer is completely useless lol.
An error would suggest that one needs to assign a SoundFont in order to use those methods. In fact, it's so crucial to SoundFont functionality so that it crashes without the check. If there's no practical use case for when you have no SoundFont loaded (like falling back to default library, for instance), it makes sense to me to print an error in those cases.
Goost and Godot version: 608257a2bd15395cd8188ebc122c12e02a303a6a
OS/platform/device including version: Windows 10
Issue description: Issue detected by fuzzer: https://github.com/goostengine/goost-fuzzer/actions/runs/1523496655
Steps to reproduce:
Only happens if MidiFile is null.