Replace malloc with calloc to initialize the buffers[] as NULL in do_get_buffers function
The calling for allocate_or_reuse_buffer may fail due to some reason, e.g. out of memory. If the buffers[] were not initialized to be NULL, the following err_out may try to access an illegal memory, which will cause X crash afterward. Reviewed-by: Kristian Høgsberg <krh@bitplanet.net> Signed-off-by: Justin Dou <Justin.Dou@intel.com> Signed-off-by: Keith Packard <keithp@keithp.com>
This commit is contained in:
parent
0bc9b15a62
commit
a73c28f0bd
|
@ -403,7 +403,7 @@ do_get_buffers(DrawablePtr pDraw, int *width, int *height,
|
|||
&& (pDraw->height == pPriv->height)
|
||||
&& (pPriv->serialNumber == DRI2DrawableSerial(pDraw));
|
||||
|
||||
buffers = malloc((count + 1) * sizeof(buffers[0]));
|
||||
buffers = calloc((count + 1), sizeof(buffers[0]));
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
const unsigned attachment = *(attachments++);
|
||||
|
|
Loading…
Reference in New Issue
Block a user