cvs: gd /libgd ISSUES gd.c

From: Date: Wed, 03 Jan 2007 19:42:12 +0000
Subject: cvs: gd /libgd ISSUES gd.c
Groups: php.gd.cvs 
Request: Send a blank email to php-gd-cvs+get-44@lists.php.net to get a copy of this message
pajoye Wed Jan 3 19:42:12 2007 UTC Modified files: /gd/libgd gd.c ISSUES Log: - #16, Added sanity checks in gdImageCreate for possible allocation failures (John Ellson/Graphviz) http://cvs.php.net/viewvc.cgi/gd/libgd/gd.c?r1=1.36&r2=1.37&diff_format=u Index: gd/libgd/gd.c diff -u gd/libgd/gd.c:1.36 gd/libgd/gd.c:1.37 --- gd/libgd/gd.c:1.36 Wed Nov 8 12:23:24 2006 +++ gd/libgd/gd.c Wed Jan 3 19:42:12 2007 @@ -1,4 +1,4 @@ -/* $Id: gd.c,v 1.36 2006/11/08 12:23:24 pajoye Exp $ */ +/* $Id: gd.c,v 1.37 2007/01/03 19:42:12 pajoye Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -79,9 +79,18 @@ } im = (gdImage *) gdMalloc (sizeof (gdImage)); + if (!im) { + return NULL; + } + memset (im, 0, sizeof (gdImage)); /* Row-major ever since gd 1.3 */ im->pixels = (unsigned char **) gdMalloc (sizeof (unsigned char *) * sy); + if (!im->pixels) { + gdFree(im); + return NULL; + } + im->polyInts = 0; im->polyAllocated = 0; im->brush = 0; @@ -91,6 +100,16 @@ { /* Row-major ever since gd 1.3 */ im->pixels[i] = (unsigned char *) gdCalloc (sx, sizeof (unsigned char)); + if (!im->pixels[i]) + { + for (--i ; i >= 0; i--) + { + gdFree(im->pixels[i]); + } + gdFree(im); + return NULL; + } + } im->sx = sx; im->sy = sy; http://cvs.php.net/viewvc.cgi/gd/libgd/ISSUES?r1=1.14&r2=1.15&diff_format=u Index: gd/libgd/ISSUES diff -u gd/libgd/ISSUES:1.14 gd/libgd/ISSUES:1.15 --- gd/libgd/ISSUES:1.14 Wed Jan 3 19:14:00 2007 +++ gd/libgd/ISSUES Wed Jan 3 19:42:12 2007 @@ -35,3 +35,5 @@ #14, Fixed leak in jinit_2pass_quantizer (gd_topal.c) #15, gdImageCreatePaletteFromTrueColor(), colors allocated henceforth from the resulting image overwrite the palette colors (Rob Leslie) +#16, Added sanity checks in gdImageCreate for possible allocation failures + (John Ellson/Graphviz)

« previous php.gd.cvs (#44) next »