summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorisanae <14251494+isanae@users.noreply.github.com>2021-01-16 16:56:35 -0500
committerGitHub <noreply@github.com>2021-01-16 16:56:35 -0500
commit8ee1f94b0f695be46abce2f76ee96035e1d79df7 (patch)
tree227b1d08db5c69531c458259a1084a6c1156adff /src
parent899308b31d541e78a3e4395bf33cd66c5ec4f769 (diff)
parent9092c096d54b123de8d118265ede89e3bee81e9c (diff)
Merge pull request #1365 from isanae/master
Fix crash on bad bsa
Diffstat (limited to 'src')
-rw-r--r--src/shared/directoryentry.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/shared/directoryentry.cpp b/src/shared/directoryentry.cpp
index 0d275844..badb5636 100644
--- a/src/shared/directoryentry.cpp
+++ b/src/shared/directoryentry.cpp
@@ -211,7 +211,19 @@ void DirectoryEntry::addFromBSA(
}
BSA::Archive archive;
- BSA::EErrorCode res = archive.read(ToString(archivePath, false).c_str(), false);
+ BSA::EErrorCode res = BSA::ERROR_NONE;
+
+ try
+ {
+ // read() can return an error, but it can also throw if the file is not a
+ // valid bsa
+ res = archive.read(ToString(archivePath, false).c_str(), false);
+ }
+ catch(std::exception& e)
+ {
+ log::error("invalid bsa '{}', error {}", archivePath, e.what());
+ return;
+ }
if ((res != BSA::ERROR_NONE) && (res != BSA::ERROR_INVALIDHASHES)) {
log::error("invalid bsa '{}', error {}", archivePath, res);