From e9e1bb1bc6453c2bb3face5772b37ef510c66eb2 Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 9 Apr 2021 18:21:36 +0200 Subject: [PATCH] dtoolutil/express: Resolving empty filename should yield no result See #1140 - I may revert this if someone can demonstrate a compelling use case (for current directory, you can use "." instead), but it seems to have the potential to cause unintuitive behavior. --- dtool/src/dtoolutil/dSearchPath.cxx | 4 ++++ panda/src/express/virtualFileSystem.cxx | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/dtool/src/dtoolutil/dSearchPath.cxx b/dtool/src/dtoolutil/dSearchPath.cxx index c17b3d61ec..b8c388c804 100644 --- a/dtool/src/dtoolutil/dSearchPath.cxx +++ b/dtool/src/dtoolutil/dSearchPath.cxx @@ -242,6 +242,10 @@ get_directory(size_t n) const { */ Filename DSearchPath:: find_file(const Filename &filename) const { + if (filename.empty()) { + return string(); + } + if (filename.is_local()) { if (_directories.empty()) { // Let's say an empty search path is the same as a search path diff --git a/panda/src/express/virtualFileSystem.cxx b/panda/src/express/virtualFileSystem.cxx index 3d02eed6a8..0092d9943e 100644 --- a/panda/src/express/virtualFileSystem.cxx +++ b/panda/src/express/virtualFileSystem.cxx @@ -649,6 +649,10 @@ find_file(const Filename &filename, const DSearchPath &searchpath, return get_file(filename, status_only); } + if (filename.empty()) { + return nullptr; + } + int num_directories = searchpath.get_num_directories(); for (int i = 0; i < num_directories; ++i) { Filename match(searchpath.get_directory(i), filename);