Skip to content

Commit

Permalink
Add check to LoadFile to check for fileToLoad == nullptr before c…
Browse files Browse the repository at this point in the history
…alling `ReadResourceInitDataLegacy` to prevent crashes from trying to assign to a null container with files of 0 size. (#802)
  • Loading branch information
Malkierian authored Jan 27, 2025
1 parent d6fcebf commit 5341b01
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/resource/archive/Archive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,10 @@ std::shared_ptr<File> Archive::LoadFile(const std::string& filePath, std::shared
fileToLoad->InitData = initDataFromMetaFile;
} else {
fileToLoad = LoadFileRaw(filePath);
if (fileToLoad == nullptr) {
SPDLOG_ERROR("Failed to load file at path {}.", filePath);
return nullptr;
}
fileToLoad->InitData = ReadResourceInitDataLegacy(filePath, fileToLoad);
}
}
Expand Down

0 comments on commit 5341b01

Please sign in to comment.