shithub: puzzles

Download patch

ref: 4e09175fdaaffc0483fc9bf767311268794d956c
parent: 1235f05af70c3acea7eedb0cbfd726ab4ec357c4
author: Ben Harris <[email protected]>
date: Mon Feb 20 09:50:22 EST 2023

Fix memory leak in midend_game_id_int()

The "par" string wasn't getting freed on some error paths.  Fixed by
freeing it immediately after its last use, which is before any of the
error paths.

--- a/midend.c
+++ b/midend.c
@@ -1801,6 +1801,7 @@
             newcurparams = me->ourgame->default_params();
         }
         me->ourgame->decode_params(newcurparams, par);
+        sfree(par);
         error = me->ourgame->validate_params(newcurparams, desc == NULL);
         if (error) {
             me->ourgame->free_params(newcurparams);
@@ -1875,8 +1876,6 @@
         me->seedstr = dupstr(seed);
         me->genmode = GOT_SEED;
     }
-
-    sfree(par);
 
     me->newgame_can_store_undo = false;