gstbuffer: Fix range iteration

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
This commit is contained in:
Edward Hervey 2014-04-11 13:45:21 +02:00
parent 876af7b343
commit c7295cf4b9

View 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;