dri2: Handle calloc() failure

Don't access invalid memory if calloc() fails to allocate the buffers
array.

Signed-off-by: Ville Syrjälä <ville.syrjala@nokia.com>
Reviewed-by: Tiago Vignatti <tiago.vignatti@nokia.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
This commit is contained in:
Ville Syrjälä 2011-04-12 17:13:28 +03:00
parent b2997431fd
commit 93c833ee84

View File

@ -409,6 +409,8 @@ do_get_buffers(DrawablePtr pDraw, int *width, int *height,
&& (pPriv->serialNumber == DRI2DrawableSerial(pDraw));
buffers = calloc((count + 1), sizeof(buffers[0]));
if (!buffers)
goto err_out;
for (i = 0; i < count; i++) {
const unsigned attachment = *(attachments++);
@ -501,13 +503,15 @@ err_out:
*out_count = 0;
for (i = 0; i < count; i++) {
if (buffers) {
for (i = 0; i < count; i++) {
if (buffers[i] != NULL)
(*ds->DestroyBuffer)(pDraw, buffers[i]);
}
(*ds->DestroyBuffer)(pDraw, buffers[i]);
}
free(buffers);
buffers = NULL;
free(buffers);
buffers = NULL;
}
update_dri2_drawable_buffers(pPriv, pDraw, buffers, out_count, width, height);