typefind: handle map failure
authorWim Taymans <wim.taymans@collabora.co.uk>
Mon, 14 Jan 2013 16:01:22 +0000 (17:01 +0100)
committerWim Taymans <wim.taymans@collabora.co.uk>
Mon, 14 Jan 2013 16:01:22 +0000 (17:01 +0100)
libs/gst/base/gsttypefindhelper.c

index f6289a9..42c058a 100644 (file)
@@ -176,7 +176,12 @@ helper_find_peek (gpointer data, gint64 offset, guint size)
   }
 
   bmap = g_slice_new0 (GstMappedBuffer);
+
+  if (!gst_buffer_map (buffer, &bmap->map, GST_MAP_READ))
+    goto map_failed;
+
   bmap->buffer = buffer;
+
   if (insert_pos) {
     helper->buffers = g_slist_insert_before (helper->buffers, insert_pos, bmap);
   } else {
@@ -187,8 +192,6 @@ helper_find_peek (gpointer data, gint64 offset, guint size)
     helper->buffers = g_slist_prepend (helper->buffers, bmap);
   }
 
-  gst_buffer_map (buffer, &bmap->map, GST_MAP_READ);
-
   return bmap->map.data;
 
 error:
@@ -196,6 +199,13 @@ error:
     GST_INFO ("typefind function returned: %s", gst_flow_get_name (ret));
     return NULL;
   }
+map_failed:
+  {
+    GST_ERROR ("map failed");
+    gst_buffer_unref (buffer);
+    g_slice_free (GstMappedBuffer, bmap);
+    return NULL;
+  }
 }
 
 /*