Commit ebcf8759 authored by Neal Norwitz's avatar Neal Norwitz

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)
parent 0f7dbf73
......@@ -410,6 +410,11 @@ longimagedata(PyObject *self, PyObject *args)
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 @@ longimagedata(PyObject *self, PyObject *args)
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;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment