glwindow: remove window from display list on quit/finalize

Fixes a possible use-after-free in the X11 backend.
This commit is contained in:
Matthew Waters 2019-03-08 17:40:52 +11:00 committed by GStreamer Merge Bot
parent d79d742492
commit b29d61b88e
2 changed files with 9 additions and 1 deletions

View file

@ -592,8 +592,11 @@ gst_gl_display_create_window (GstGLDisplay * display)
window = klass->create_window (display);
if (window)
if (window) {
display->windows = g_list_prepend (display->windows, window);
}
GST_DEBUG_OBJECT (display, "Adding window %" GST_PTR_FORMAT
" (%p) to internal list", window, window);
return window;
}
@ -625,6 +628,8 @@ gst_gl_display_remove_window (GstGLDisplay * display, GstGLWindow * window)
display->windows = g_list_delete_link (display->windows, l);
ret = TRUE;
}
GST_DEBUG_OBJECT (display, "Removing window %" GST_PTR_FORMAT
" (%p) from internal list", window, window);
GST_OBJECT_UNLOCK (display);
return ret;

View file

@ -317,6 +317,8 @@ gst_gl_window_finalize (GObject * object)
GstGLWindow *window = GST_GL_WINDOW (object);
GstGLWindowPrivate *priv = window->priv;
gst_gl_display_remove_window (window->display, window);
if (priv->loop)
g_main_loop_unref (priv->loop);
@ -540,6 +542,7 @@ gst_gl_window_run (GstGLWindow * window)
static void
gst_gl_window_default_quit (GstGLWindow * window)
{
gst_gl_display_remove_window (window->display, window);
g_main_loop_quit (window->priv->loop);
}