From ff6442f6f998d70421076931d91a322d6dabe05c Mon Sep 17 00:00:00 2001 From: Dominique Martinet Date: Tue, 1 Jun 2021 08:40:17 +0900 Subject: gst-libs/gst/wayland: handle display passing better failure to pass a display in 'handle' would result in uninitialized value being returned, which would often segfault later down the road when trying to initialize gstreamer context with it. Check the return value of gst_structure_get() to make sure we return valid data. Furthermore, the gstglimagesink in gst-plugins-base also has a similar mechanism but uses 'display' as field name to pass the value; instead of requiring the application to behave differently depending on what sink was automatically detected just try to read both values here, with display being the new default. Part-of: --- gst-libs/gst/wayland/wayland.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'gst-libs/gst') diff --git a/gst-libs/gst/wayland/wayland.c b/gst-libs/gst/wayland/wayland.c index 9e01d8e98..3ee7a98d3 100644 --- a/gst-libs/gst/wayland/wayland.c +++ b/gst-libs/gst/wayland/wayland.c @@ -46,7 +46,7 @@ gst_wayland_display_handle_context_new (struct wl_display * display) GstContext *context = gst_context_new (GST_WAYLAND_DISPLAY_HANDLE_CONTEXT_TYPE, TRUE); gst_structure_set (gst_context_writable_structure (context), - "handle", G_TYPE_POINTER, display, NULL); + "display", G_TYPE_POINTER, display, NULL); return context; } @@ -59,8 +59,11 @@ gst_wayland_display_handle_context_get_handle (GstContext * context) g_return_val_if_fail (GST_IS_CONTEXT (context), NULL); s = gst_context_get_structure (context); - gst_structure_get (s, "handle", G_TYPE_POINTER, &display, NULL); - return display; + if (gst_structure_get (s, "display", G_TYPE_POINTER, &display, NULL)) + return display; + if (gst_structure_get (s, "handle", G_TYPE_POINTER, &display, NULL)) + return display; + return NULL; } -- cgit v1.2.1