queuearray: fix expanding size of queue from 1
authorEvan Nemerson <evan@nemerson.com>
Fri, 6 Jun 2014 23:36:00 +0000 (16:36 -0700)
committerTim-Philipp Müller <tim@centricular.com>
Sat, 7 Jun 2014 08:45:39 +0000 (09:45 +0100)
Without we would not actually expand and access
memory beyond the allocated region for the array.

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

libs/gst/base/gstqueuearray.c

index 8061ff1..d37535d 100644 (file)
@@ -145,7 +145,7 @@ gst_queue_array_push_tail (GstQueueArray * array, gpointer data)
   /* Check if we need to make room */
   if (G_UNLIKELY (array->length == array->size)) {
     /* newsize is 50% bigger */
-    guint newsize = (3 * array->size) / 2;
+    guint newsize = MAX ((3 * array->size) / 2, array->size + 1);
 
     /* copy over data */
     if (array->tail != 0) {