[Python-checkins] r51232 - python/trunk/Modules/rgbimgmodule.c
neal.norwitz
python-checkins at python.org
Sat Aug 12 05:18:51 CEST 2006
Author: neal.norwitz
Date: Sat Aug 12 05:18:50 2006
New Revision: 51232
Modified:
python/trunk/Modules/rgbimgmodule.c
Log:
Verify verdat which is returned from malloc is not NULL.
Ensure we don't pass NULL to free.
Klocwork #306 (at least the first part, checking malloc)
Modified: python/trunk/Modules/rgbimgmodule.c
==============================================================================
--- python/trunk/Modules/rgbimgmodule.c (original)
+++ python/trunk/Modules/rgbimgmodule.c Sat Aug 12 05:18:50 2006
@@ -410,6 +410,11 @@
addlongimgtag(base, xsize, ysize);
#endif
verdat = (unsigned char *)malloc(xsize);
+ if (!verdat) {
+ Py_CLEAR(rv);
+ goto finally;
+ }
+
fseek(inf, 512, SEEK_SET);
for (z = 0; z < zsize; z++) {
lptr = base;
@@ -431,10 +436,14 @@
copybw((Py_Int32 *) base, xsize * ysize);
}
finally:
- free(starttab);
- free(lengthtab);
- free(rledat);
- free(verdat);
+ if (starttab)
+ free(starttab);
+ if (lengthtab)
+ free(lengthtab);
+ if (rledat)
+ free(rledat);
+ if (verdat)
+ free(verdat);
fclose(inf);
return rv;
}
More information about the Python-checkins
mailing list