From 713a3750116774da61ee875efc74c1416e22bb51 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 27 Feb 2014 20:37:17 -0500 Subject: [PATCH] (backport from cairocanvas branch) do not crash when considering a directory called midi (with any case) as an apparent MIDI file --- libs/ardour/smf_source.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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 +#include #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;