mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 20:21:24 +00:00
miniobject: Fix dup_mini_object function to handle NULL gvalues
g_value_dup_object handles gvalues that contain NULL pointers, gst_value_dup_mini_object should do the same. https://bugzilla.gnome.org/show_bug.cgi?id=649195
This commit is contained in:
parent
511f556915
commit
a750aac2dd
2 changed files with 24 additions and 4 deletions
|
@ -427,8 +427,8 @@ gst_value_mini_object_copy (const GValue * src_value, GValue * dest_value)
|
|||
{
|
||||
if (src_value->data[0].v_pointer) {
|
||||
dest_value->data[0].v_pointer =
|
||||
gst_mini_object_ref (GST_MINI_OBJECT_CAST (src_value->data[0].
|
||||
v_pointer));
|
||||
gst_mini_object_ref (GST_MINI_OBJECT_CAST (src_value->
|
||||
data[0].v_pointer));
|
||||
} else {
|
||||
dest_value->data[0].v_pointer = NULL;
|
||||
}
|
||||
|
@ -544,7 +544,8 @@ gst_value_get_mini_object (const GValue * value)
|
|||
* @value: a valid #GValue of %GST_TYPE_MINI_OBJECT derived type
|
||||
*
|
||||
* Get the contents of a %GST_TYPE_MINI_OBJECT derived #GValue,
|
||||
* increasing its reference count.
|
||||
* increasing its reference count. If the contents of the #GValue
|
||||
* are %NULL, %NULL will be returned.
|
||||
*
|
||||
* Returns: (transfer full): mini object contents of @value
|
||||
*
|
||||
|
@ -555,7 +556,8 @@ gst_value_dup_mini_object (const GValue * value)
|
|||
{
|
||||
g_return_val_if_fail (GST_VALUE_HOLDS_MINI_OBJECT (value), NULL);
|
||||
|
||||
return gst_mini_object_ref (value->data[0].v_pointer);
|
||||
return value->data[0].v_pointer ? gst_mini_object_ref (value->data[0].
|
||||
v_pointer) : NULL;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -447,6 +447,23 @@ GST_START_TEST (test_value_collection)
|
|||
GST_END_TEST;
|
||||
|
||||
|
||||
GST_START_TEST (test_dup_null_mini_object)
|
||||
{
|
||||
GValue value = { 0, };
|
||||
GstBuffer *buf;
|
||||
|
||||
g_value_init (&value, GST_TYPE_BUFFER);
|
||||
|
||||
gst_value_set_mini_object (&value, NULL);
|
||||
|
||||
buf = gst_value_dup_mini_object (&value);
|
||||
g_assert (buf == NULL);
|
||||
|
||||
g_value_unset (&value);
|
||||
}
|
||||
|
||||
GST_END_TEST;
|
||||
|
||||
static Suite *
|
||||
gst_mini_object_suite (void)
|
||||
{
|
||||
|
@ -464,6 +481,7 @@ gst_mini_object_suite (void)
|
|||
tcase_add_test (tc_chain, test_unref_threaded);
|
||||
tcase_add_test (tc_chain, test_recycle_threaded);
|
||||
tcase_add_test (tc_chain, test_value_collection);
|
||||
tcase_add_test (tc_chain, test_dup_null_mini_object);
|
||||
return s;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue