Skip to content

Commit 5341b01

Browse files
authored
Add check to LoadFile to check for fileToLoad == nullptr before calling ReadResourceInitDataLegacy to prevent crashes from trying to assign to a null container with files of 0 size. (Kenix3#802)
1 parent d6fcebf commit 5341b01

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/resource/archive/Archive.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,10 @@ std::shared_ptr<File> Archive::LoadFile(const std::string& filePath, std::shared
218218
fileToLoad->InitData = initDataFromMetaFile;
219219
} else {
220220
fileToLoad = LoadFileRaw(filePath);
221+
if (fileToLoad == nullptr) {
222+
SPDLOG_ERROR("Failed to load file at path {}.", filePath);
223+
return nullptr;
224+
}
221225
fileToLoad->InitData = ReadResourceInitDataLegacy(filePath, fileToLoad);
222226
}
223227
}

0 commit comments

Comments
 (0)