[gst-cvs] gstreamer: structures: don't leak invalid or empty strings when we warn

Tim Mueller tpm at kemper.freedesktop.org
Mon Jun 1 02:10:51 PDT 2009


Module: gstreamer
Branch: master
Commit: a565dbd1f32b6a9a87866e8ccc25017db516e62e
URL:    http://cgit.freedesktop.org/gstreamer/gstreamer/commit/?id=a565dbd1f32b6a9a87866e8ccc25017db516e62e

Author: Tim-Philipp Müller <tim.muller at collabora.co.uk>
Date:   Mon Jun  1 10:05:32 2009 +0100

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.

---

 gst/gststructure.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/gst/gststructure.c b/gst/gststructure.c
index af1243a..a43b9e7 100644
--- a/gst/gststructure.c
+++ b/gst/gststructure.c
@@ -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;
     }
   }





More information about the Gstreamer-commits mailing list