From e29f231e5d032fea63a55ba0258a4ab3e2b13f67 Mon Sep 17 00:00:00 2001 From: Chris Clayton Date: Mon, 8 Jun 2015 19:42:30 +0100 Subject: [PATCH] rtpvp8depay: potential access beyond end of array Compiling (with gcc-4.9-20150603) produces an error because of an access beyond the end of an array. This patch fixes the error by initializing the loop control/array index variable (i) to 1 and returning i - 1 when a match is found. Also, because the values stored in the array increase in value as the index increases, the >= test unnecessary, so it is removed. --- gst/rtp/gstrtpvp8pay.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/gst/rtp/gstrtpvp8pay.c b/gst/rtp/gstrtpvp8pay.c index 133c2fd82a..d611520cde 100644 --- a/gst/rtp/gstrtpvp8pay.c +++ b/gst/rtp/gstrtpvp8pay.c @@ -350,13 +350,12 @@ gst_rtp_vp8_offset_to_partition (GstRtpVP8Pay * self, guint offset) { int i; - for (i = 0; i < self->n_partitions; i++) { - if (offset >= self->partition_offset[i] && - offset < self->partition_offset[i + 1]) - return i; + for (i = 1; i < self->n_partitions; i++) { + if (offset < self->partition_offset[i]) + return i - 1; } - return i; + return i - 1; } static gsize