bufferlist: Add check for overflow
authorEdward Hervey <edward@centricular.com>
Wed, 18 Mar 2020 10:10:13 +0000 (11:10 +0100)
committerEdward Hervey <bilboed@bilboed.com>
Wed, 18 Mar 2020 10:10:13 +0000 (11:10 +0100)
gst/gstbufferlist.c

index 2c1359769e2ee5e529a6bb5e13ca8ea16c524c4e..59fbcafc5f9ab649ebbd99fef365bd2a2eb068c4 100644 (file)
@@ -436,6 +436,9 @@ gst_buffer_list_insert (GstBufferList * list, gint idx, GstBuffer * buffer)
   want_alloc = list->n_buffers + 1;
 
   if (want_alloc > list->n_allocated) {
+    if (G_UNLIKELY (list->n_allocated > (G_MAXUINT / 2)))
+      g_error ("Growing GstBufferList would result in overflow");
+
     want_alloc = MAX (GST_ROUND_UP_16 (want_alloc), list->n_allocated * 2);
 
     if (GST_BUFFER_LIST_IS_USING_DYNAMIC_ARRAY (list)) {