dmabuf: Ref previous context

In case the context's only reference was held by being the current
context, setting the new context would free it.

Resetting it later would then be a use-after-free.

Fixes #6694
This commit is contained in:
Benjamin Otte 2024-05-06 20:23:47 +02:00
parent 84a98f74c1
commit bc17dfa83d

View File

@ -163,6 +163,8 @@ gdk_dmabuf_get_egl_downloader (GdkDisplay *display,
return NULL;
previous = gdk_gl_context_get_current ();
if (previous)
g_object_ref (previous);
formats = gdk_dmabuf_formats_builder_new ();
external = gdk_dmabuf_formats_builder_new ();
@ -194,7 +196,10 @@ gdk_dmabuf_get_egl_downloader (GdkDisplay *display,
}
if (previous)
{
gdk_gl_context_make_current (previous);
g_object_unref (previous);
}
return GDK_DMABUF_DOWNLOADER (renderer);
}