From: Stefan Kost Date: Mon, 20 Jul 2009 13:11:02 +0000 (+0300) Subject: gstregistrybinary: add +1 after error checking X-Git-Tag: RELEASE-0.10.24~11 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1a44bd93d686176793aebf1e56d0308286b58329;p=platform%2Fupstream%2Fgstreamer.git gstregistrybinary: add +1 after error checking The current code made the error checking pointless by changing -1 to 0 in error cases. Also don't leak a pad template on error. --- diff --git a/gst/gstregistrybinary.c b/gst/gstregistrybinary.c index d305948..aacb414 100644 --- a/gst/gstregistrybinary.c +++ b/gst/gstregistrybinary.c @@ -97,19 +97,19 @@ _strnlen (const gchar * str, gint maxlen) }G_STMT_END #define unpack_const_string(inptr, outptr, endptr, error_label) G_STMT_START{\ - gint _len = _strnlen (inptr, (endptr-inptr)) + 1; \ + gint _len = _strnlen (inptr, (endptr-inptr)); \ if (_len == -1) \ goto error_label; \ outptr = g_intern_string ((const gchar *)inptr); \ - inptr += _len; \ + inptr += _len + 1; \ }G_STMT_END #define unpack_string(inptr, outptr, endptr, error_label) G_STMT_START{\ - gint _len = _strnlen (inptr, (endptr-inptr)) + 1; \ + gint _len = _strnlen (inptr, (endptr-inptr)); \ if (_len == -1) \ goto error_label; \ - outptr = g_memdup ((gconstpointer)inptr, _len); \ - inptr += _len; \ + outptr = g_memdup ((gconstpointer)inptr, _len + 1); \ + inptr += _len + 1; \ }G_STMT_END #define ALIGNMENT (sizeof (void *)) @@ -868,7 +868,7 @@ gst_registry_binary_load_pad_template (GstElementFactory * factory, gchar ** in, gchar * end) { GstBinaryPadTemplate *pt; - GstStaticPadTemplate *template; + GstStaticPadTemplate *template = NULL; align (*in); GST_DEBUG ("Reading/casting for GstBinaryPadTemplate at address %p", *in); @@ -889,6 +889,7 @@ gst_registry_binary_load_pad_template (GstElementFactory * factory, gchar ** in, fail: GST_INFO ("Reading pad template failed"); + g_free (template); return FALSE; }