]> git.imager.perl.org - imager.git/commitdiff
i_img_make_palette() no longer leaks on quantization failure
authorTony Cook <tony@develop-help.com>
Mon, 25 Feb 2019 22:39:57 +0000 (09:39 +1100)
committerTony Cook <tony@develop-help.com>
Mon, 25 Feb 2019 22:39:57 +0000 (09:39 +1100)
CID 185566

Imager.xs

index c20b418f55f888f8a8356b924c1f016a5d7f8122..7b6433df8cdccd8893ddf8a3aead11e4a47e02e9 100644 (file)
--- a/Imager.xs
+++ b/Imager.xs
@@ -3266,14 +3266,13 @@ i_img_make_palette(HV *quant_hv, ...)
       PPCODE:
         if (count <= 0)
          croak("Please supply at least one image (%d)", (int)count);
-        imgs = mymalloc(sizeof(i_img *) * count);
+       imgs = malloc_temp(aTHX_ count * sizeof(i_img *));
        for (i = 0; i < count; ++i) {
          SV *img_sv = ST(i + 1);
          if (SvROK(img_sv) && sv_derived_from(img_sv, "Imager::ImgRaw")) {
            imgs[i] = INT2PTR(i_img *, SvIV((SV*)SvRV(img_sv)));
          }
          else {
-           myfree(imgs);
            croak("Image %d is not an image object", (int)i+1);
           }
        }
@@ -3290,7 +3289,6 @@ i_img_make_palette(HV *quant_hv, ...)
          PUSHs(sv_c);
        }
        ip_cleanup_quant_opts(aTHX_ &quant);
-        myfree(imgs);
        
 
 void