From cba9942f7716b12c329616a9994c5bce857617fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Mon, 17 May 2010 17:40:30 -0400 Subject: [PATCH] dri2: Fix NULL check in allocation error handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Tested-by: Eric Anholt Signed-off-by: Keith Packard --- hw/xfree86/dri2/dri2.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c index 68982fe3e..29c917f21 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) goto err_out; + i++; have_fake_front = 1; }