From 8f13c69e7658df3a97e388f210dae175639d6d8d Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Fri, 16 Jul 2010 12:24:53 +0100 Subject: [PATCH] intel: Fix invalidate before initialisation Fixes: Bug 29091 - 1.9RC5 server crash when starting GLX 1.3 app with mesa 7.8 Intel dri2 driver. https://bugs.freedesktop.org/show_bug.cgi?id=29091 Signed-off-by: Chris Wilson --- src/mesa/drivers/dri/common/dri_util.c | 2 +- src/mesa/drivers/dri/intel/intel_screen.c | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c index 75c9882..9a9bfed 100644 --- a/src/mesa/drivers/dri/common/dri_util.c +++ b/src/mesa/drivers/dri/common/dri_util.c @@ -432,7 +432,7 @@ driCreateNewDrawable(__DRIscreen *psp, const __DRIconfig *config, */ (void) attrs; - pdp = malloc(sizeof *pdp); + pdp = calloc(1, sizeof *pdp); if (!pdp) { return NULL; } diff --git a/src/mesa/drivers/dri/intel/intel_screen.c b/src/mesa/drivers/dri/intel/intel_screen.c index 6e4bb64..083b7bb 100644 --- a/src/mesa/drivers/dri/intel/intel_screen.c +++ b/src/mesa/drivers/dri/intel/intel_screen.c @@ -102,10 +102,21 @@ static const __DRItexBufferExtension intelTexBufferExtension = { intelSetTexBuffer2, }; +static inline struct intel_context * +to_intel_context(__DRIdrawable *drawable) +{ + if (drawable->driContextPriv == NULL) + return NULL; + + return drawable->driContextPriv->driverPrivate; +} + static void intelDRI2Flush(__DRIdrawable *drawable) { - struct intel_context *intel = drawable->driContextPriv->driverPrivate; + struct intel_context *intel = to_intel_context(drawable); + if (!intel) + return; if (intel->gen < 4) INTEL_FIREVERTICES(intel); @@ -117,9 +128,9 @@ intelDRI2Flush(__DRIdrawable *drawable) static void intelDRI2Invalidate(__DRIdrawable *drawable) { - struct intel_context *intel = drawable->driContextPriv->driverPrivate; - - intel->using_dri2_swapbuffers = GL_TRUE; + struct intel_context *intel = to_intel_context(drawable); + if (intel) + intel->using_dri2_swapbuffers = GL_TRUE; dri2InvalidateDrawable(drawable); } -- 1.7.1