aboutsummaryrefslogtreecommitdiff
path: root/launcher
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@users.noreply.github.com>2021-11-06 23:07:23 +0100
committerGitHub <noreply@github.com>2021-11-06 23:07:23 +0100
commit30602363d7879ba82d0153082858b0cd6a1a4c9e (patch)
treedd5013c001c91204e0d3511d81c459505b607b95 /launcher
parent7b4c52e1e32803a6a9c6c19cfa3becf4f2dc623c (diff)
parent0423464b88a0d25442fbb50f4b94db73757b6126 (diff)
downloadPrismLauncher-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
Diffstat (limited to 'launcher')
-rw-r--r--launcher/minecraft/mod/LocalModParseTask.cpp11
1 files changed, 11 insertions, 0 deletions
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");