[Mesa-dev] [PATCH 1/2] i965: Don't leave dangling pointer to brw context on failure
Ian Romanick
idr at freedesktop.org
Wed Sep 26 11:12:22 PDT 2012
From: Ian Romanick <ian.d.romanick at intel.com>
Otherwise intelDestroyContext would try to dereference the pointer to
freed memory.
v2: Don't call intelDestroyContext if the context already freed due to
failure.
NOTE: This is a candidate for the 9.0 branch.
Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=54301
---
src/mesa/drivers/dri/i965/brw_context.c | 1 +
src/mesa/drivers/dri/intel/intel_screen.c | 4 +++-
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c
index 1083e28..60b6454 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -149,6 +149,7 @@ brwCreateContext(int api,
sharedContextPrivate, &functions )) {
printf("%s: failed to init intel context\n", __FUNCTION__);
free(brw);
+ driContextPriv->driverPrivate = NULL;
*error = __DRI_CTX_ERROR_NO_MEMORY;
return false;
}
diff --git a/src/mesa/drivers/dri/intel/intel_screen.c b/src/mesa/drivers/dri/intel/intel_screen.c
index e3a442c..6ae78d2 100644
--- a/src/mesa/drivers/dri/intel/intel_screen.c
+++ b/src/mesa/drivers/dri/intel/intel_screen.c
@@ -821,7 +821,9 @@ intelCreateContext(gl_api api,
if (success)
return true;
- intelDestroyContext(driContextPriv);
+ if (driContextPriv->driverPrivate != NULL)
+ intelDestroyContext(driContextPriv);
+
return false;
}
--
1.7.11.4
More information about the mesa-dev
mailing list