]> granicus.if.org Git - php/commitdiff
Replace regular malloc with safe_emalloc in several places.
authorIlia Alshanetsky <iliaa@php.net>
Wed, 31 Dec 2003 01:01:44 +0000 (01:01 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Wed, 31 Dec 2003 01:01:44 +0000 (01:01 +0000)
ext/gd/libgd/gd_topal.c
ext/gd/libgd/wbmp.c

index b2c64d9ba8e7a4363cb401d9642a36e61086d14e..68c74aa4032fae6c7a81a87f45260426967cae7c 100644 (file)
@@ -765,7 +765,7 @@ select_colors (gdImagePtr im, my_cquantize_ptr cquantize, int desired_colors)
 #ifdef ORIGINAL_LIB_JPEG
        boxlist = (boxptr) (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, desired_colors * SIZEOF (box));
 #else
-       boxlist = (boxptr) gdMalloc (desired_colors * sizeof (box));
+       boxlist = (boxptr) safe_emalloc(desired_colors, sizeof(box), 1);
 #endif
        /* Initialize one box containing whole space */
        numboxes = 1;
@@ -1518,7 +1518,7 @@ init_error_limit (gdImagePtr im, my_cquantize_ptr cquantize)
        my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;
        table = (int *) (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE * 2 + 1) * SIZEOF (int));
 #else
-       cquantize->error_limiter_storage = (int *) gdMalloc ((MAXJSAMPLE * 2 + 1) * sizeof (int));
+       cquantize->error_limiter_storage = (int *) safe_emalloc((MAXJSAMPLE * 2 + 1), sizeof(int), 0);
        if (!cquantize->error_limiter_storage) {
                return;
        }
@@ -1719,9 +1719,9 @@ gdImageTrueColorToPalette (gdImagePtr im, int dither, int colorsWanted)
        }
        cquantize->needs_zeroed = TRUE; /* histogram is garbage now */
 #else
-       cquantize->histogram = (hist3d) gdMalloc (HIST_C0_ELEMS * sizeof (hist2d));
+       cquantize->histogram = (hist3d) safe_emalloc(HIST_C0_ELEMS, sizeof(hist2d), 0);
        for (i = 0; i < HIST_C0_ELEMS; i++) {
-               cquantize->histogram[i] = (hist2d) gdMalloc(HIST_C1_ELEMS * HIST_C2_ELEMS * sizeof (histcell));
+               cquantize->histogram[i] = (hist2d) safe_emalloc(HIST_C1_ELEMS, HIST_C2_ELEMS * sizeof(histcell), 0);
        }
 #endif
 
@@ -1891,7 +1891,7 @@ int gdImageColorMatch (gdImagePtr im1, gdImagePtr im2)
                return -3; /* the images are meant to be the same dimensions */
        }
 
-       buf = (unsigned long *)gdMalloc( sizeof(unsigned long) * 5 * im2->colorsTotal );
+       buf = (unsigned long *)safe_emalloc(sizeof(unsigned long), 5 * im2->colorsTotal, 0);
        memset( buf, 0, sizeof(unsigned long) * 5 * im2->colorsTotal );
 
        for (x=0; x<im1->sx; x++) {
index fad35669222eff088859606b89e3491ba0fd1cf9..d63c684ac792451513f6d1969e9f862685893a25 100644 (file)
@@ -116,7 +116,7 @@ createwbmp (int width, int height, int color)
   if ((wbmp = (Wbmp *) gdMalloc (sizeof (Wbmp))) == NULL)
     return (NULL);
 
-  if ((wbmp->bitmap = (int *) gdMalloc (sizeof (int) * width * height)) == NULL)
+  if ((wbmp->bitmap = (int *) safe_emalloc(sizeof(int), width * height, 0)) == NULL)
     {
       gdFree (wbmp);
       return (NULL);