gstbuffer: Fix range iteration
authorEdward Hervey <bilboed@bilboed.com>
Fri, 11 Apr 2014 11:45:21 +0000 (13:45 +0200)
committerEdward Hervey <bilboed@bilboed.com>
Fri, 11 Apr 2014 11:45:21 +0000 (13:45 +0200)
We want to iterate over items idx to idx + length

We use the len variable as the corrected number of memory to iterate
and then properly go over all items.

Fixes the issue where specifying any idx different from 0 had no effect

Spotted by clang static analyzer

gst/gstbuffer.c

index 019261e..1cea700 100644 (file)
@@ -1204,10 +1204,12 @@ gst_buffer_is_memory_range_writable (GstBuffer * buffer, guint idx, gint length)
       FALSE);
 
   if (length == -1)
-    length = len - idx;
+    len -= idx;
+  else
+    len = length;
 
   for (i = 0; i < len; i++) {
-    if (!gst_memory_is_writable (GST_BUFFER_MEM_PTR (buffer, i)))
+    if (!gst_memory_is_writable (GST_BUFFER_MEM_PTR (buffer, i + idx)))
       return FALSE;
   }
   return TRUE;