1
0
mirror of synced 2024-09-25 03:58:27 +02:00

fix: Properly Check if crash.json has valid json, remove it otherwise (#1117)

This commit is contained in:
iTrooz 2023-05-28 11:35:51 +02:00 committed by GitHub
parent 0ba011dbe1
commit e599d31625
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -439,8 +439,15 @@ namespace hex::plugin::builtin {
log::info("Found crash.json file at {}", wolv::util::toUTF8String(crashFilePath));
wolv::io::File crashFile(crashFilePath, wolv::io::File::Mode::Read);
auto crashFileData = nlohmann::json::parse(crashFile.readString());
crashFile.close();
nlohmann::json crashFileData;
try {
crashFileData = nlohmann::json::parse(crashFile.readString());
} catch (nlohmann::json::exception &e) {
log::error("Failed to parse crash.json file: {}", e.what());
crashFile.remove();
continue;
}
bool hasProject = !crashFileData.value("project", "").empty();
auto backupFilePath = path / BackupFileName;