shithub: puzzles

Download patch

ref: 1dc1ed786fda790f60f2fe9f8e7c404c73ae64da
parent: 4b5422181deb3b09a7926aa51a7b26d656ca15ba
author: Ben Hutchings <[email protected]>
date: Sun Jan 15 19:07:01 EST 2023

Fix memory leak in convert_tilesize

If old_dpr == new_dpr, convert_tilesize returns early without freeing
defaults.  Move the initialisation of defaults after this special
case.

--- a/midend.c
+++ b/midend.c
@@ -321,10 +321,13 @@
                             double old_dpr, double new_dpr)
 {
     int x, y, rx, ry, min, max;
-    game_params *defaults = me->ourgame->default_params();
+    game_params *defaults;
 
     if (new_dpr == old_dpr)
         return old_tilesize;
+
+    defaults = me->ourgame->default_params();
+
     me->ourgame->compute_size(defaults, old_tilesize, &x, &y);
     x *= new_dpr / old_dpr;
     y *= new_dpr / old_dpr;