diff options
author | Petr Mrázek <peterix@users.noreply.github.com> | 2021-11-06 23:07:23 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-06 23:07:23 +0100 |
commit | 30602363d7879ba82d0153082858b0cd6a1a4c9e (patch) | |
tree | dd5013c001c91204e0d3511d81c459505b607b95 | |
parent | 7b4c52e1e32803a6a9c6c19cfa3becf4f2dc623c (diff) | |
parent | 0423464b88a0d25442fbb50f4b94db73757b6126 (diff) | |
download | PrismLauncher-30602363d7879ba82d0153082858b0cd6a1a4c9e.tar.gz PrismLauncher-30602363d7879ba82d0153082858b0cd6a1a4c9e.tar.bz2 PrismLauncher-30602363d7879ba82d0153082858b0cd6a1a4c9e.zip |
Merge pull request #4229 from Janrupf/develop
GH-4227 Don't crash when mods.toml is invalid
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | launcher/minecraft/mod/LocalModParseTask.cpp | 11 |
2 files changed, 12 insertions, 0 deletions
@@ -32,3 +32,4 @@ tags branding/ secrets/ +run/ diff --git a/launcher/minecraft/mod/LocalModParseTask.cpp b/launcher/minecraft/mod/LocalModParseTask.cpp index 0d6972fb..8ac5885f 100644 --- a/launcher/minecraft/mod/LocalModParseTask.cpp +++ b/launcher/minecraft/mod/LocalModParseTask.cpp @@ -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"); |