Просмотр исходного кода

vfs: Correct file_p variable usage within InterpretAsDirectory()

ReplaceFileWithSubdirectory() takes a VirtualFile and a VirtualDir, but
it was being passed a string as one of its arguments. The only reason
this never caused issues is because this template isn't instantiated
anywhere yet.

This corrects an issue before it occurs.
Lioncash 8 лет назад
Родитель
Сommit
0081252d31
1 измененных файлов с 5 добавлено и 2 удалено
  1. 5 2
      src/core/file_sys/vfs.h

+ 5 - 2
src/core/file_sys/vfs.h

@@ -205,9 +205,12 @@ struct VfsDirectory : NonCopyable {
     template <typename Directory>
     bool InterpretAsDirectory(std::string_view file) {
         auto file_p = GetFile(file);
-        if (file_p == nullptr)
+
+        if (file_p == nullptr) {
             return false;
-        return ReplaceFileWithSubdirectory(file, std::make_shared<Directory>(file_p));
+        }
+
+        return ReplaceFileWithSubdirectory(file_p, std::make_shared<Directory>(file_p));
     }
 
 protected: