From 66e21d1e70c66cf7fe9980a1e252f26a30cea0f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Qian=20Hu=20=28=E8=83=A1=E9=AA=9E=29?= Date: Fri, 22 Nov 2024 21:23:10 +0800 Subject: [PATCH] gstvalue: fix crash in transform allocation params to string 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: --- subprojects/gstreamer/gst/gstvalue.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/subprojects/gstreamer/gst/gstvalue.c b/subprojects/gstreamer/gst/gstvalue.c index cf29a1db3f..137fe70cc3 100644 --- a/subprojects/gstreamer/gst/gstvalue.c +++ b/subprojects/gstreamer/gst/gstvalue.c @@ -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; }