plug a memleak in _gdImageFillTiled() on error condition

replace a malloc+memset with calloc instance
master
nlopess 2007-06-17 18:56:28 +00:00
parent 3582807a58
commit 9d05dd439d
1 changed files with 2 additions and 2 deletions

View File

@ -80,12 +80,11 @@ BGD_DECLARE(gdImagePtr) gdImageCreate (int sx, int sy)
return NULL;
}
im = (gdImage *) gdMalloc (sizeof (gdImage));
im = (gdImage *) gdCalloc(1, 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) {
@ -2028,6 +2027,7 @@ static void _gdImageFillTiled(gdImagePtr im, int x, int y, int nc)
stack = (struct seg *)gdMalloc(sizeof(struct seg) * ((int)(im->sy*im->sx)/4));
if (!stack) {
gdFree(pts);
return;
}
sp = stack;