Add an extra test to prevent 'PBD::path_is_within()' from looping infinitely on Windows
authorJohn Emmas <johne53@tiscali.co.uk>
Tue, 3 Feb 2015 11:57:38 +0000 (11:57 +0000)
committerJohn Emmas <johne53@tiscali.co.uk>
Tue, 3 Feb 2015 11:57:38 +0000 (11:57 +0000)
The infinite loop would happen if the 2 supplied paths were on different Windows drives - for example if one was on drive C:\ and the other on drive E:\

I don't think this new test will be detrimental to the other platforms but if it is, we could easily separate it out with a '#ifdef PLATFORM_WINDOWS' directive.

libs/pbd/file_utils.cc

index f8ab326c5bd021ef3b982c4d4d9d7e93f6126d1f..9523fdd6bdbd5bd7d6379146d574daa7fe556aef 100644 (file)
@@ -379,7 +379,7 @@ path_is_within (std::string const & haystack, std::string needle)
                }
 
                needle = Glib::path_get_dirname (needle);
-               if (needle == "." || needle == "/") {
+               if (needle == "." || needle == "/" || Glib::path_skip_root(needle).empty()) {
                        break;
                }
        }