shithub: puzzles

Download patch

ref: 3e7a6adce5887db04d26438da64fdc4de308f4da
parent: 9e4e15fda22e0ed8e5c6ea671f17bd76ead0d317
author: Asher Gordon <[email protected]>
date: Sat Jul 29 11:27:46 EDT 2023

midend_get_prefs: Don't free memory that we just copied elsewhere.

We were using free_cfg(be_prefs) after we copied be_prefs to
all_prefs, but we actually want to use sfree(be_prefs) since we don't
want to free each element that has been copied. None of the games so
far use string preferences, which is why they haven't been affected by
this bug.

--- a/midend.c
+++ b/midend.c
@@ -2937,7 +2937,9 @@
     all_prefs[pos].type = C_END;
 
     if (be_prefs)
-        free_cfg(be_prefs);
+        /* We already copied each element, so don't free those with
+           free_cfg(). */
+        sfree(be_prefs);
 
     return all_prefs;
 }