shithub: libvpx

Download patch

ref: 6aa308abfb681b532c67cda0070c98d830db3549
parent: 313ca263fab12963d06a84d6d1c31092369d8742
parent: e6d2dc12adcabb5e387188f616f31e3219660029
author: Fyodor Kyslov <kyslov@google.com>
date: Fri Dec 21 18:24:29 EST 2018

Merge "Bound the total allocated memory of frame buffer"

--- a/vpx_scale/generic/yv12config.c
+++ b/vpx_scale/generic/yv12config.c
@@ -15,6 +15,9 @@
 #include "vpx_mem/vpx_mem.h"
 #include "vpx_ports/mem.h"
 
+#if defined(VPX_MAX_ALLOCABLE_MEMORY)
+#include "vp9/common/vp9_onyxc_int.h"
+#endif  // VPX_MAX_ALLOCABLE_MEMORY
 /****************************************************************************
  *  Exports
  ****************************************************************************/
@@ -184,6 +187,13 @@
 #endif  // CONFIG_VP9_HIGHBITDEPTH
 
     uint8_t *buf = NULL;
+
+#if defined(VPX_MAX_ALLOCABLE_MEMORY)
+    // The decoder may allocate REF_FRAMES frame buffers in the frame buffer
+    // pool. Bound the total amount of allocated memory as if these REF_FRAMES
+    // frame buffers were allocated in a single allocation.
+    if (frame_size > VPX_MAX_ALLOCABLE_MEMORY / REF_FRAMES) return -1;
+#endif  // VPX_MAX_ALLOCABLE_MEMORY
 
     // frame_size is stored in buffer_alloc_sz, which is a size_t. If it won't
     // fit, fail early.