printf: don't leak serialised pointer extension strings
authorTim-Philipp Müller <tim@centricular.net>
Sun, 7 Apr 2013 16:21:10 +0000 (17:21 +0100)
committerTim-Philipp Müller <tim.muller@collabora.co.uk>
Fri, 12 Apr 2013 22:05:57 +0000 (23:05 +0100)
gst/printf/vasnprintf.c

index 315688c..f20d3bc 100644 (file)
@@ -260,10 +260,15 @@ vasnprintf (char *resultbuf, size_t * lengthp, const char *format, va_list args)
     errno = EINVAL;
     return NULL;
   }
-#define CLEANUP() \
-  free (d.dir);                                                                \
-  if (a.arg)                                                           \
-    free (a.arg);
+#define CLEANUP()                         \
+  free (d.dir);                           \
+  if (a.arg) {                            \
+    while (a.count--) {                   \
+      if (a.arg[a.count].ext_string)      \
+        free (a.arg[a.count].ext_string); \
+    }                                     \
+    free (a.arg);                         \
+  }
 
   if (printf_fetchargs (args, &a) < 0) {
     CLEANUP ();