diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2014-02-27 20:35:23 -0500 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2014-02-27 20:35:52 -0500 |
commit | dc4bb5b7580c42426cd76da45fdc913374814c0d (patch) | |
tree | 9cf6136372b1edd006db1ea2be2235a455cc1aef /libs | |
parent | b8e4c446374bcb2c47b35f1f9e2ee5dd7cfba6c3 (diff) |
do not crash when considering a directory called midi (with any case) as an apparent MIDI file
Diffstat (limited to 'libs')
-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 dfaa51481d..c504f50006 100644 --- a/libs/ardour/smf_source.cc +++ b/libs/ardour/smf_source.cc @@ -32,6 +32,7 @@ #include <glib/gstdio.h> #include <glibmm/miscutils.h> +#include <glibmm/fileutils.h> #include "evoral/Control.hpp" @@ -464,7 +465,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; |