Merge pull request #4229 from Janrupf/develop

GH-4227 Don't crash when mods.toml is invalid
This commit is contained in:
Petr Mrázek 2021-11-06 23:07:23 +01:00 committed by GitHub
commit 30602363d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 0 deletions

1
.gitignore vendored
View File

@ -32,3 +32,4 @@ tags
branding/
secrets/
run/

View File

@ -107,8 +107,19 @@ std::shared_ptr<ModDetails> ReadMCModTOML(QByteArray contents)
// array defined by [[mods]]
toml_array_t* tomlModsArr = toml_array_in(tomlData, "mods");
if(!tomlModsArr)
{
qWarning() << "Corrupted mods.toml? Couldn't find [[mods]] array!";
return nullptr;
}
// we only really care about the first element, since multiple mods in one file is not supported by us at the moment
toml_table_t* tomlModsTable0 = toml_table_at(tomlModsArr, 0);
if(!tomlModsTable0)
{
qWarning() << "Corrupted mods.toml? [[mods]] didn't have an element at index 0!";
return nullptr;
}
// mandatory properties - always in [[mods]]
toml_datum_t modIdDatum = toml_string_in(tomlModsTable0, "modId");