do not crash when considering a directory called midi (with any case) as an apparent...
authorPaul Davis <paul@linuxaudiosystems.com>
Fri, 28 Feb 2014 01:35:23 +0000 (20:35 -0500)
committerPaul Davis <paul@linuxaudiosystems.com>
Fri, 28 Feb 2014 01:35:52 +0000 (20:35 -0500)
libs/ardour/smf_source.cc

index dfaa51481d352a4e1fb32b407a76260640fd3d32..c504f5000628f67008c0a6e5478194414f952435 100644 (file)
@@ -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;