aboutsummaryrefslogtreecommitdiff
path: root/midend.c
diff options
context:
space:
mode:
Diffstat (limited to 'midend.c')
-rw-r--r--midend.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/midend.c b/midend.c
index 10f6810..175b6f1 100644
--- a/midend.c
+++ b/midend.c
@@ -2091,6 +2091,7 @@ void midend_serialise(midend *me,
char buf[80];
sprintf(buf, "%d", me->nstates);
wr("NSTATES", buf);
+ assert(me->statepos >= 1 && me->statepos <= me->nstates);
sprintf(buf, "%d", me->statepos);
wr("STATEPOS", buf);
}
@@ -2345,8 +2346,9 @@ static const char *midend_deserialise_internal(
ret = "Game private description in save file is invalid";
goto cleanup;
}
- if (data.statepos < 0 || data.statepos >= data.nstates) {
+ if (data.statepos < 1 || data.statepos > data.nstates) {
ret = "Game position in save file is out of range";
+ goto cleanup;
}
if (!data.states) {