addon/mg: Ensure _info.cfg has an [info] node when reading it

Fixes the dreaded "Mandatory WML child missing yet untested for. Please
report" error occurring when reading _info.cfg files that don't have a
valid [info] tag. In particular, this would cause the game version
dialog to crash to desktop.
This commit is contained in:
Iris Morelle 2020-12-10 03:21:00 -03:00
parent 9252b7b024
commit 070b7eddde
2 changed files with 3 additions and 1 deletions

View file

@ -1,4 +1,6 @@
## Version 1.14.14+dev
### Add-ons client
* Fix potential crashes when working with installed add-ons that have a corrupted _info.cfg file.
### Campaigns
* Descent into Darkness:
* S11: fix low probability case of enemy being unreachable

View file

@ -175,7 +175,7 @@ std::map<std::string, std::string> installed_addons_and_versions()
} else if(filesystem::file_exists(get_info_file_path(addon_id))) {
config temp;
get_addon_install_info(addon_id, temp);
addons[addon_id] = !temp.empty() ? temp.child("info")["version"].str() : "Unknown";
addons[addon_id] = !temp.empty() && temp.has_child("info") ? temp.child("info")["version"].str() : "Unknown";
} else {
addons[addon_id] = "Unknown";
}