diff options
| author | Ben Harris <bjh21@bjh21.me.uk> | 2023-02-13 09:31:03 +0000 |
|---|---|---|
| committer | Ben Harris <bjh21@bjh21.me.uk> | 2023-02-13 09:39:04 +0000 |
| commit | bb31efdbc91495a4385ca0afffa4c8bb8f564d7b (patch) | |
| tree | 7845313ad01cff6751319263dc053e11d4371431 | |
| parent | c139aba078f2ec46a0e0b44142b7c982519a8263 (diff) | |
| download | puzzles-bb31efdbc91495a4385ca0afffa4c8bb8f564d7b.zip puzzles-bb31efdbc91495a4385ca0afffa4c8bb8f564d7b.tar.gz puzzles-bb31efdbc91495a4385ca0afffa4c8bb8f564d7b.tar.bz2 puzzles-bb31efdbc91495a4385ca0afffa4c8bb8f564d7b.tar.xz | |
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.
| -rw-r--r-- | keen.c | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -1310,8 +1310,10 @@ static const char *validate_desc(const game_params *params, const char *desc) return ret; } - if (*p != ',') + if (*p != ',') { + sfree(dsf); return "Expected ',' after block structure description"; + } p++; /* @@ -1323,17 +1325,22 @@ static const char *validate_desc(const game_params *params, const char *desc) if (*p == 'a' || *p == 'm') { /* these clues need no validation */ } 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"; + } } else if (!*p) { + sfree(dsf); return "Too few clues for block structure"; } else { + sfree(dsf); return "Unrecognised clue type"; } p++; while (*p && isdigit((unsigned char)*p)) p++; } } + sfree(dsf); if (*p) return "Too many clues for block structure"; |