From c59965ad4faca67be0dad554bc291a97f2691dff Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 24 Jul 2012 18:49:01 +0200 Subject: WINTERMUTE: Make sure we don't skip path-components. --- engines/wintermute/base/file/base_disk_file.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'engines/wintermute/base/file/base_disk_file.cpp') diff --git a/engines/wintermute/base/file/base_disk_file.cpp b/engines/wintermute/base/file/base_disk_file.cpp index 09a83f5768..c03a9b61e7 100644 --- a/engines/wintermute/base/file/base_disk_file.cpp +++ b/engines/wintermute/base/file/base_disk_file.cpp @@ -69,14 +69,19 @@ static Common::FSNode getNodeForRelativePath(const Common::String& filename) { Common::String pathPart = path.nextToken(); // Get the next FSNode in the chain, if it exists as a child from the previous. Common::FSNode nextNode(curNode.getChild(pathPart)); + if (!nextNode.exists()) { + // Return an invalid FSNode. + return Common::FSNode(); + } if (nextNode.exists() && nextNode.isReadable()) { curNode = nextNode; } // Following the comments in common/fs.h, anything not a directory is a file. if (!curNode.isDirectory()) { - assert(path.empty()); + if (!path.empty()) { + error("Relative path %s reached a file before the end of the path", filename.c_str()); + } return curNode; - break; } } } -- cgit v1.2.3