[PATCH] dri2: Fix NULL check in allocation error handling

Kristian Høgsberg krh at bitplanet.net
Mon May 17 14:36:15 PDT 2010


1461b31e40a3e44f6327199d23cf2ab70d8f5176 tests to see if the allocation
of buffer[i] failed after i has been incremented, causing it to look
at the wrong pointer.

Signed-off-by: Kristian Høgsberg <krh at bitplanet.net>
---
 hw/xfree86/dri2/dri2.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
index 68982fe..9e799de 100644
--- a/hw/xfree86/dri2/dri2.c
+++ b/hw/xfree86/dri2/dri2.c
@@ -421,22 +421,24 @@ do_get_buffers(DrawablePtr pDraw, int *width, int *height,
     if (need_real_front > 0) {
 	if (allocate_or_reuse_buffer(pDraw, ds, pPriv, DRI2BufferFrontLeft,
 				     front_format, dimensions_match,
-				     &buffers[i++]))
+				     &buffers[i]))
 	    buffers_changed = 1;
 
 	if (buffers[i] == NULL)
 	    goto err_out;
+	i++;
     }
 
     if (need_fake_front > 0) {
 	if (allocate_or_reuse_buffer(pDraw, ds, pPriv, DRI2BufferFakeFrontLeft,
 				     front_format, dimensions_match,
-				     &buffers[i++]))
+				     &buffers[i]))
 	    buffers_changed = 1;
 
-	if (buffers[i] == NULL)
+	if (buffers[i - 1] == NULL)
 	    goto err_out;
 
+	i++;
 	have_fake_front = 1;
     }
 
-- 
1.7.0.1



More information about the xorg-devel mailing list