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:
Tim-Philipp Müller 2009-06-01 10:05:32 +01:00
parent fc866b82db
commit a565dbd1f3

View file

@ -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;
}
}