ebml: don't modify out str if returning an error in _read_ascii
authorPhilip Jägenstedt <philipj@opera.com>
Thu, 13 May 2010 07:18:56 +0000 (09:18 +0200)
committerSebastian Dröge <sebastian.droege@collabora.co.uk>
Wed, 19 May 2010 18:35:06 +0000 (20:35 +0200)
This is a regression from ASCII validation changes. Test case:
bug_s66876390_r0.001____malloc_printerr.webm

gst/matroska/ebml-read.c

index e53027a..6ea70f2 100644 (file)
@@ -802,28 +802,30 @@ gst_ebml_read_string (GstEbmlRead * ebml, guint32 * id, gchar ** str)
  */
 
 GstFlowReturn
-gst_ebml_read_ascii (GstEbmlRead * ebml, guint32 * id, gchar ** str)
+gst_ebml_read_ascii (GstEbmlRead * ebml, guint32 * id, gchar ** str_out)
 {
   GstFlowReturn ret;
+  gchar *str;
   gchar *iter;
 
 #ifndef GST_DISABLE_GST_DEBUG
   guint64 oldoff = ebml->offset;
 #endif
 
-  ret = gst_ebml_read_string (ebml, id, str);
+  ret = gst_ebml_read_string (ebml, id, &str);
   if (ret != GST_FLOW_OK)
     return ret;
 
-  for (iter = *str; *iter != '\0'; iter++) {
+  for (iter = str; *iter != '\0'; iter++) {
     if (G_UNLIKELY (*iter & 0x80)) {
       GST_ERROR_OBJECT (ebml,
           "Invalid ASCII string at offset %" G_GUINT64_FORMAT, oldoff);
-      g_free (*str);
+      g_free (str);
       return GST_FLOW_ERROR;
     }
   }
 
+  *str_out = str;
   return ret;
 }