shithub: puzzles

Download patch

ref: 3e006158451a7ff8f130cbcb7dd80f165a58396e
parent: 640f9235c79cdb1a924b0148cb312b0f02253364
author: Simon Tatham <anakin@pobox.com>
date: Sat Dec 11 06:03:20 EST 2021

Map: add missing sresize in new_game_desc().

Every time we append to the string 'ret', we check first that there's
enough space, and realloc it larger if it's getting close to full.
Except that I missed one case at the join between the two parts of the
encoding.

(Spotted because apparently on someone's build platform this led to a
compiler warning that 'ret' might be null. I think _that's_ not a
serious worry, but the missing resize was definitely unintentional.)

--- a/map.c
+++ b/map.c
@@ -1659,6 +1659,10 @@
 	    }
 	}
 
+        if (retlen + 10 >= retsize) {
+            retsize = retlen + 256;
+            ret = sresize(ret, retsize, char);
+        }
 	ret[retlen++] = 'a'-1 + run;
 	ret[retlen++] = ',';