aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2014-11-26 21:25:02 +0000
committerSimon Tatham <anakin@pobox.com>2014-11-26 21:25:02 +0000
commit078d3c0a6d6ace0f524dea0c3e03d5fa9ba361c0 (patch)
tree372338014c0cf8975404e37ad7044e00a4a33c1d
parentd7a4c52937ddacc5c81049f0bfdf916df757277c (diff)
downloadpuzzles-078d3c0a6d6ace0f524dea0c3e03d5fa9ba361c0.zip
puzzles-078d3c0a6d6ace0f524dea0c3e03d5fa9ba361c0.tar.gz
puzzles-078d3c0a6d6ace0f524dea0c3e03d5fa9ba361c0.tar.bz2
puzzles-078d3c0a6d6ace0f524dea0c3e03d5fa9ba361c0.tar.xz
Remove an inappropriate assertion in validation context.
spec_to_dsf() should not report invalid input by failing an assertion, because one of the contexts it's called from is validate_desc(), in which the whole point is to present a useful error message to the user before getting to the point where an assertion might go off at all. Game description 5j:c1_5o4_3c,c___aba___cca_a_a_aca now fails validation cleanly, where previously it would trigger this bug.
-rw-r--r--solo.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/solo.c b/solo.c
index c7ed61b..789d68f 100644
--- a/solo.c
+++ b/solo.c
@@ -3849,7 +3849,11 @@ static char *spec_to_dsf(const char **pdesc, int **pdsf, int cr, int area)
* Non-edge; merge the two dsf classes on either
* side of it.
*/
- assert(pos < 2*cr*(cr-1));
+ if (pos >= 2*cr*(cr-1)) {
+ sfree(dsf);
+ return "Too much data in block structure specification";
+ }
+
if (pos < cr*(cr-1)) {
int y = pos/(cr-1);
int x = pos%(cr-1);