-
-
Save Milek7/dec057a5d9e1029884822d64c0811dbc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/saveload/gamelog_sl.cpp b/src/saveload/gamelog_sl.cpp | |
index 6bff1b154..f8df687ab 100644 | |
--- a/src/saveload/gamelog_sl.cpp | |
+++ b/src/saveload/gamelog_sl.cpp | |
@@ -107,8 +107,12 @@ static void Load_GLOG_common(LoggedAction *&gamelog_action, uint &gamelog_action | |
assert(gamelog_action == nullptr); | |
assert(gamelog_actions == 0); | |
+ byte type; | |
GamelogActionType at; | |
- while ((at = (GamelogActionType)SlReadByte()) != GLAT_NONE) { | |
+ while ((type = SlReadByte()) != GLAT_NONE) { | |
+ if (type >= GLAT_END) SlErrorCorrupt("Invalid gamelog action type"); | |
+ at = (GamelogActionType)type; | |
+ | |
gamelog_action = ReallocT(gamelog_action, gamelog_actions + 1); | |
LoggedAction *la = &gamelog_action[gamelog_actions++]; | |
@@ -119,7 +123,10 @@ static void Load_GLOG_common(LoggedAction *&gamelog_action, uint &gamelog_action | |
la->changes = 0; | |
GamelogChangeType ct; | |
- while ((ct = (GamelogChangeType)SlReadByte()) != GLCT_NONE) { | |
+ while ((type = SlReadByte()) != GLCT_NONE) { | |
+ if (type >= GLCT_END) SlErrorCorrupt("Invalid gamelog change type"); | |
+ ct = (GamelogChangeType)type; | |
+ | |
la->change = ReallocT(la->change, la->changes + 1); | |
LoggedChange *lc = &la->change[la->changes++]; | |
@@ -127,8 +134,6 @@ static void Load_GLOG_common(LoggedAction *&gamelog_action, uint &gamelog_action | |
memset(lc, 0, sizeof(*lc)); | |
lc->ct = ct; | |
- assert((uint)ct < GLCT_END); | |
- | |
SlObject(lc, _glog_desc[ct]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment