summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatric Stout <truebrain@openttd.org>2021-07-17 17:26:50 +0200
committerGitHub <noreply@github.com>2021-07-17 17:26:50 +0200
commitab601115a906a576d4af53509a8ee14e455f6a3f (patch)
tree3cdddcb9c30703dbd6cc65d9050196487251ac95
parent460991ecf4fbeca2c0f8c39874b39a0885d6f67d (diff)
downloadopenttd-ab601115a906a576d4af53509a8ee14e455f6a3f.tar.xz
Fix 75b6051b: removing items from the ini could leave the group in a bad state (#9445)
-rw-r--r--src/ini_load.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/ini_load.cpp b/src/ini_load.cpp
index 0663ef1e4..06d6efb33 100644
--- a/src/ini_load.cpp
+++ b/src/ini_load.cpp
@@ -112,8 +112,9 @@ void IniGroup::RemoveItem(const std::string &name)
if (item->name != name) continue;
*prev = item->next;
- if (this->last_item == &this->item) {
- this->last_item = &item->next;
+ /* "last_item" is a pointer to the "real-last-item"->next. */
+ if (this->last_item == &item->next) {
+ this->last_item = prev;
}
item->next = nullptr;