diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2014-02-27 20:37:17 -0500 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2014-02-27 20:37:17 -0500 |
commit | 713a3750116774da61ee875efc74c1416e22bb51 (patch) | |
tree | 4ed01b7008e881bec9372642f95e2166fac41fa9 /libs/ardour/smf_source.cc | |
parent | ce4d125d1fd91bb3cdf82319dcce53abb35afcca (diff) |
(backport from cairocanvas branch) do not crash when considering a directory called midi (with any case) as an apparent MIDI file
Diffstat (limited to 'libs/ardour/smf_source.cc')
-rw-r--r-- | libs/ardour/smf_source.cc | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/libs/ardour/smf_source.cc b/libs/ardour/smf_source.cc index b2d01d24d2..52c950e76f 100644 --- a/libs/ardour/smf_source.cc +++ b/libs/ardour/smf_source.cc @@ -31,6 +31,7 @@ #include "pbd/strsplit.h" #include <glibmm/miscutils.h> +#include <glibmm/fileutils.h> #include "evoral/Control.hpp" @@ -463,7 +464,14 @@ SMFSource::safe_midi_file_extension (const string& file) const int nmatches = 2; regmatch_t matches[nmatches]; - if (compile && regcomp (&compiled_pattern, "[mM][iI][dD][iI]?$", REG_EXTENDED)) { + if (Glib::file_test (file, Glib::FILE_TEST_EXISTS)) { + if (!Glib::file_test (file, Glib::FILE_TEST_IS_REGULAR)) { + /* exists but is not a regular file */ + return false; + } + } + + if (compile && regcomp (&compiled_pattern, "\\.[mM][iI][dD][iI]?$", REG_EXTENDED)) { return false; } else { compile = false; |