aboutsummaryrefslogtreecommitdiff
path: root/launcher/minecraft/mod/LocalModParseTask.cpp
diff options
context:
space:
mode:
authorJanrupf <business.janrupf@gmail.com>2021-11-06 22:42:10 +0100
committerJanrupf <business.janrupf@gmail.com>2021-11-06 22:43:16 +0100
commit0423464b88a0d25442fbb50f4b94db73757b6126 (patch)
treedd5013c001c91204e0d3511d81c459505b607b95 /launcher/minecraft/mod/LocalModParseTask.cpp
parent2576a28f73f0f345dfa6fff745fb163efb3bde6c (diff)
downloadPrismLauncher-0423464b88a0d25442fbb50f4b94db73757b6126.tar.gz
PrismLauncher-0423464b88a0d25442fbb50f4b94db73757b6126.tar.bz2
PrismLauncher-0423464b88a0d25442fbb50f4b94db73757b6126.zip
GH-4227 Don't blindly trust mods.toml to be valid
Diffstat (limited to 'launcher/minecraft/mod/LocalModParseTask.cpp')
-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");