summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichel Dänzer <michel.daenzer@amd.com>2014-04-21 17:47:15 +0900
committerEric Anholt <eric@anholt.net>2014-04-22 12:29:38 -0700
commit429df19b03d81e7e0e19274e171377047653a363 (patch)
tree630627c1aebe58c0c6844544a34952054eefa6cc
parente119db5eb70ee790a25b88e7f25ca6762751ff6f (diff)
glx: If DRI2GetBuffers changes the GL context, call it againglamor-gl-context-2
By changing the context, it may also invalidate the DRI2 buffer information, so we need to get that again. Fixes crashes due to use-after-free with LIBGL_ALWAYS_INDIRECT=1 glxgears and piglit. Signed-off-by: Michel Dänzer <michel.daenzer@amd.com> Signed-off-by: Eric Anholt <eric@anholt.net> Reviewed-by: Eric Anholt <eric@anholt.net>
-rw-r--r--glx/glxdri2.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/glx/glxdri2.c b/glx/glxdri2.c
index 7b368d2d6..c756bf570 100644
--- a/glx/glxdri2.c
+++ b/glx/glxdri2.c
@@ -676,6 +676,13 @@ dri2GetBuffers(__DRIdrawable * driDrawable,
if (cx != lastGLContext) {
lastGLContext = cx;
cx->makeCurrent(cx);
+
+ /* If DRI2GetBuffers() changed the GL context, it may also have
+ * invalidated the DRI2 buffers, so let's get them again
+ */
+ buffers = DRI2GetBuffers(private->base.pDraw,
+ width, height, attachments, count, out_count);
+ assert(lastGLContext == cx);
}
if (*out_count > MAX_DRAWABLE_BUFFERS) {
@@ -727,6 +734,14 @@ dri2GetBuffersWithFormat(__DRIdrawable * driDrawable,
if (cx != lastGLContext) {
lastGLContext = cx;
cx->makeCurrent(cx);
+
+ /* If DRI2GetBuffersWithFormat() changed the GL context, it may also have
+ * invalidated the DRI2 buffers, so let's get them again
+ */
+ buffers = DRI2GetBuffersWithFormat(private->base.pDraw,
+ width, height, attachments, count,
+ out_count);
+ assert(lastGLContext == cx);
}
if (*out_count > MAX_DRAWABLE_BUFFERS) {