mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-21 16:05:44 -07:00
Fix memory leaks in Keen's validate_desc()
Keen uses a DSF to validate its game descriptions and almost always failed to free it, even when the validation succeeded.
This commit is contained in:
11
keen.c
11
keen.c
@ -1310,8 +1310,10 @@ static const char *validate_desc(const game_params *params, const char *desc)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*p != ',')
|
if (*p != ',') {
|
||||||
|
sfree(dsf);
|
||||||
return "Expected ',' after block structure description";
|
return "Expected ',' after block structure description";
|
||||||
|
}
|
||||||
p++;
|
p++;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1323,17 +1325,22 @@ static const char *validate_desc(const game_params *params, const char *desc)
|
|||||||
if (*p == 'a' || *p == 'm') {
|
if (*p == 'a' || *p == 'm') {
|
||||||
/* these clues need no validation */
|
/* these clues need no validation */
|
||||||
} else if (*p == 'd' || *p == 's') {
|
} else if (*p == 'd' || *p == 's') {
|
||||||
if (dsf_size(dsf, i) != 2)
|
if (dsf_size(dsf, i) != 2) {
|
||||||
|
sfree(dsf);
|
||||||
return "Subtraction and division blocks must have area 2";
|
return "Subtraction and division blocks must have area 2";
|
||||||
|
}
|
||||||
} else if (!*p) {
|
} else if (!*p) {
|
||||||
|
sfree(dsf);
|
||||||
return "Too few clues for block structure";
|
return "Too few clues for block structure";
|
||||||
} else {
|
} else {
|
||||||
|
sfree(dsf);
|
||||||
return "Unrecognised clue type";
|
return "Unrecognised clue type";
|
||||||
}
|
}
|
||||||
p++;
|
p++;
|
||||||
while (*p && isdigit((unsigned char)*p)) p++;
|
while (*p && isdigit((unsigned char)*p)) p++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
sfree(dsf);
|
||||||
if (*p)
|
if (*p)
|
||||||
return "Too many clues for block structure";
|
return "Too many clues for block structure";
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user