- #18, Removed invalid gdFree call when overflow2 fails

- #17, Free im->pixels as well on error
master
pajoye 2007-01-03 20:09:01 +00:00
parent 0a331ae455
commit cfee163a5e
2 changed files with 6 additions and 2 deletions

View File

@ -39,3 +39,4 @@ GDBUGS NEWS
(John Ellson/Graphviz)
#17, Added "static" to entities_s struct declaration to avoid obscure
compiler problem on Suns (John Ellson/Graphviz)
#18, Removed invalid gdFree call when overflow2 fails

View File

@ -74,8 +74,10 @@ BGD_DECLARE(gdImagePtr) gdImageCreate (int sx, int sy)
gdImagePtr im;
if (overflow2(sizeof (unsigned char *), sy)) {
gdFree(im);
return NULL;
return NULL;
}
if (overflow2(sizeof (unsigned char *), sx)) {
return NULL;
}
im = (gdImage *) gdMalloc (sizeof (gdImage));
@ -106,6 +108,7 @@ BGD_DECLARE(gdImagePtr) gdImageCreate (int sx, int sy)
{
gdFree(im->pixels[i]);
}
gdFree(im->pixels);
gdFree(im);
return NULL;
}