mirror of
https://github.com/MultiMC/MultiMC5.git
synced 2025-01-15 19:51:31 +00:00
Merge pull request #4229 from Janrupf/develop
GH-4227 Don't crash when mods.toml is invalid
This commit is contained in:
commit
30602363d7
1
.gitignore
vendored
1
.gitignore
vendored
@ -32,3 +32,4 @@ tags
|
|||||||
|
|
||||||
branding/
|
branding/
|
||||||
secrets/
|
secrets/
|
||||||
|
run/
|
||||||
|
@ -107,8 +107,19 @@ std::shared_ptr<ModDetails> ReadMCModTOML(QByteArray contents)
|
|||||||
|
|
||||||
// array defined by [[mods]]
|
// array defined by [[mods]]
|
||||||
toml_array_t* tomlModsArr = toml_array_in(tomlData, "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
|
// 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);
|
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]]
|
// mandatory properties - always in [[mods]]
|
||||||
toml_datum_t modIdDatum = toml_string_in(tomlModsTable0, "modId");
|
toml_datum_t modIdDatum = toml_string_in(tomlModsTable0, "modId");
|
||||||
|
Loading…
Reference in New Issue
Block a user