gst_value_union fails union of two identical values.
When you call gst_value_union with two identical primitive values (either equal values in two GValue variables, or the same GValue twice), it creates a list with two copies of the value, rather than just returning a copy of the primitive value.
Expected Behavior
Showing the contents of the values, instead of the values, I would expect:
gst_value_union((int)14,(int)14) = (int)14
gst_value_union((string)"blue", (string)"blue") = (string)"blue"
Observed Behavior
what we actually get is:
gst_value_union((int)14,(int)14) = { (int)14, (int)14 }
gst_value_union((string)"blue", (string)"blue") = {(string)"blue"], (string)"blue"}
Setup
Linux (CentOS 8) GStreamer 18.0 through 21.0
Steps to reproduce the bug
int main
( int argc
, char * argv[]
)
{ GValue v1 = G_VALUE_INIT;
GValue v2 = G_VALUE_INIT;
GValue n = G_VALUE_INIT;
gst_init(&argc,&argv);
g_value_init(&v1, G_TYPE_INT);
g_value_init(&v2, G_TYPE_INT);
g_value_set_int(&v1, 15);
g_value_set_int(&v2, 15);
gst_value_union(&n, &v1, &v2);
gchar * ns = gst_value_serialize(&n);
gchar * v1s = gst_value_serialize(&v1);
gchar * v2s = gst_value_serialize(&v2);
gst_print("Union(\"%s\", \"%s\") = \"%s\"\n", v1s, v2s, ns);
return 0;
}
How reproducible is the bug?
Always.
Screenshots if relevant
Solutions you have tried
Related non-duplicate issues
Additional Information
The problem seems to stem from using gst_value_list_concat as the default operation inside gst_value_union instead of gst_value_list_merge.