gstvalue: fix crash in transform allocation params to string
authorQian Hu (胡骞) <qian.hu@mediatek.com>
Fri, 22 Nov 2024 13:23:10 +0000 (21:23 +0800)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Fri, 6 Dec 2024 12:38:53 +0000 (12:38 +0000)
when gst_buffer_pool_config_set_allocator (config, alloc, NULL);
gst_structure_to_string or GST_DEBUG (pool, "config %" GST_PTR_FORMAT,
config) will crash. this patch fix that

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7943>

subprojects/gstreamer/gst/gstvalue.c

index cf29a1db3fc6e82ad798fe33bca1a53fe55c9fb6..137fe70cc35a4bebe86ec5b144a991b991d46da0 100644 (file)
@@ -8077,16 +8077,21 @@ gst_value_transform_allocation_params_string (const GValue * value1,
 {
   GstAllocationParams *params = value1->data[0].v_pointer;
   gchar *res;
-  GstStructure *s;
 
-  s = gst_structure_new_static_str ("GstAllocationParams",
-      "flags", GST_TYPE_MEMORY_FLAGS, params->flags,
-      "align", G_TYPE_UINT64, params->align,
-      "prefix", G_TYPE_UINT64, params->prefix,
-      "padding", G_TYPE_UINT64, params->padding, NULL);
+  if (params) {
+    GstStructure *s = NULL;
 
-  res = gst_structure_to_string (s);
-  gst_structure_free (s);
+    s = gst_structure_new_static_str ("GstAllocationParams",
+        "flags", GST_TYPE_MEMORY_FLAGS, params->flags,
+        "align", G_TYPE_UINT64, params->align,
+        "prefix", G_TYPE_UINT64, params->prefix,
+        "padding", G_TYPE_UINT64, params->padding, NULL);
+
+    res = gst_structure_to_string (s);
+    gst_structure_free (s);
+  } else {
+    res = g_strdup ("NULL");
+  }
 
   dest_value->data[0].v_pointer = res;
 }