mirror of
https://github.com/DarkStore-3DS/DarkStore.git
synced 2026-07-03 00:39:02 +00:00
Make JSON reading safer
- Check that the file actually opened before reading it - If the JSON was discarded, then make just use an empty object
This commit is contained in:
@@ -231,6 +231,8 @@ void Store::LoadFromFile(const std::string &file) {
|
||||
|
||||
this->storeJson = nlohmann::json::parse(in, nullptr, false);
|
||||
fclose(in);
|
||||
if (this->storeJson.is_discarded())
|
||||
this->storeJson = { };
|
||||
|
||||
/* Check, if valid. */
|
||||
if (this->storeJson.contains("storeInfo") && this->storeJson.contains("storeContent")) {
|
||||
|
||||
Reference in New Issue
Block a user