mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-03-30 12:49:40 +00:00
structures: don't leak invalid or empty strings when we warn
Fixes minor memory leak in unit tests caused by the recent changes. Since we're expected to take ownership of the GValue in the structure field struct here, we need to unset it if we don't use it.
This commit is contained in:
parent
fc866b82db
commit
a565dbd1f3
1 changed files with 3 additions and 0 deletions
|
@ -655,18 +655,21 @@ gst_structure_set_field (GstStructure * structure, GstStructureField * field)
|
|||
if (G_UNLIKELY (s == NULL && IS_TAGLIST (structure))) {
|
||||
g_warning ("Trying to set NULL string on field '%s' on taglist. "
|
||||
"Please file a bug.", g_quark_to_string (field->name));
|
||||
g_value_unset (&field->value);
|
||||
return;
|
||||
} else if (G_UNLIKELY (s != NULL && *s == '\0')) {
|
||||
/* empty strings never make sense */
|
||||
g_warning ("Trying to set empty string on %s field '%s'. Please file a "
|
||||
"bug.", IS_TAGLIST (structure) ? "taglist" : "structure",
|
||||
g_quark_to_string (field->name));
|
||||
g_value_unset (&field->value);
|
||||
return;
|
||||
} else if (G_UNLIKELY (s != NULL && !g_utf8_validate (s, -1, NULL))) {
|
||||
g_warning ("Trying to set string on %s field '%s', but string is not "
|
||||
"valid UTF-8. Please file a bug.",
|
||||
IS_TAGLIST (structure) ? "taglist" : "structure",
|
||||
g_quark_to_string (field->name));
|
||||
g_value_unset (&field->value);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue