diff options
| author | isanae <14251494+isanae@users.noreply.github.com> | 2021-01-16 16:53:50 -0500 |
|---|---|---|
| committer | isanae <14251494+isanae@users.noreply.github.com> | 2021-01-16 16:53:50 -0500 |
| commit | 9092c096d54b123de8d118265ede89e3bee81e9c (patch) | |
| tree | 227b1d08db5c69531c458259a1084a6c1156adff /src/shared | |
| parent | 899308b31d541e78a3e4395bf33cd66c5ec4f769 (diff) | |
fix crash on bad bsa
Diffstat (limited to 'src/shared')
| -rw-r--r-- | src/shared/directoryentry.cpp | 14 |
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);
|
