summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2018-04-08 02:05:16 +0200
committerRobin Gareus <robin@gareus.org>2018-04-08 02:09:35 +0200
commitdd5f124c60dffe6e637ed7840e501fdfc73884aa (patch)
treec7f238c9cbea35939cfd6b25da12a9cde649980a
parent518f8108ac17b241f0dfaaba76931d19ecc70cd6 (diff)
Fix crash when testing unsupported MIDI file
smf_delete() does not handle NULL, and segfaults instead. This only crashes with optimized builds. libsmf will call g_critical() earlier and in that case debug-builds call UI::handle_fatal() and ask the user to "click to exit".
-rw-r--r--libs/evoral/src/SMF.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/libs/evoral/src/SMF.cpp b/libs/evoral/src/SMF.cpp
index 60d69c8a4d..b4fa4a16c8 100644
--- a/libs/evoral/src/SMF.cpp
+++ b/libs/evoral/src/SMF.cpp
@@ -97,10 +97,11 @@ SMF::test(const std::string& path)
smf_t* test_smf = smf_load(f);
fclose(f);
- const bool success = (test_smf != NULL);
+ if (!test_smf) {
+ return false;
+ }
smf_delete(test_smf);
-
- return success;
+ return true;
}
/** Attempt to open the SMF file for reading and/or writing.