rtpbuffer: protect against empty buffers
authorWim Taymans <wim.taymans@collabora.co.uk>
Mon, 12 Nov 2012 10:17:56 +0000 (11:17 +0100)
committerWim Taymans <wim.taymans@collabora.co.uk>
Mon, 12 Nov 2012 10:18:16 +0000 (11:18 +0100)
gst-libs/gst/rtp/gstrtpbuffer.c

index b9d5675..800752e 100644 (file)
@@ -327,6 +327,9 @@ gst_rtp_buffer_map (GstBuffer * buffer, GstMapFlags flags, GstRTPBuffer * rtp)
   g_return_val_if_fail (rtp != NULL, FALSE);
   g_return_val_if_fail (rtp->buffer == NULL, FALSE);
 
+  if (gst_buffer_n_memory (buffer) < 1)
+    goto no_memory;
+
   /* map first memory, this should be the header */
   if (!gst_buffer_map_range (buffer, 0, 1, &rtp->map[0], flags))
     goto map_failed;
@@ -420,6 +423,11 @@ gst_rtp_buffer_map (GstBuffer * buffer, GstMapFlags flags, GstRTPBuffer * rtp)
   return TRUE;
 
   /* ERRORS */
+no_memory:
+  {
+    GST_ERROR ("buffer without memory");
+    return FALSE;
+  }
 map_failed:
   {
     GST_ERROR ("failed to map memory");