buffer: Check return value of gst_memory_map()
authorEdward Hervey <bilboed@bilboed.com>
Tue, 23 Feb 2016 16:23:43 +0000 (17:23 +0100)
committerEdward Hervey <bilboed@bilboed.com>
Tue, 23 Feb 2016 16:23:43 +0000 (17:23 +0100)
Only do memory operations if the memory was succesfully map'ed

https://bugzilla.gnome.org/show_bug.cgi?id=728326

gst/gstbuffer.c

index 0ee8bf3..7eb3472 100644 (file)
@@ -236,7 +236,12 @@ _get_merged_memory (GstBuffer * buffer, guint idx, guint length)
       guint8 *ptr;
 
       result = gst_allocator_alloc (NULL, size, NULL);
-      gst_memory_map (result, &dinfo, GST_MAP_WRITE);
+      if (result == NULL || !gst_memory_map (result, &dinfo, GST_MAP_WRITE)) {
+        GST_CAT_ERROR (GST_CAT_BUFFER, "Failed to map memory writable");
+        if (result)
+          gst_memory_unref (result);
+        return NULL;
+      }
 
       ptr = dinfo.data;
       left = size;