[vlc-commits] picture: set a maximum alloc size for sw buffers

Thomas Guillem git at videolan.org
Wed Nov 15 14:58:09 CET 2017


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Wed Nov 15 14:57:31 2017 +0100| [47ae93bdb7b2334afbef16bbf8836cdfadc09159] | committer: Thomas Guillem

picture: set a maximum alloc size for sw buffers

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=47ae93bdb7b2334afbef16bbf8836cdfadc09159
---

 src/misc/picture.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/misc/picture.c b/src/misc/picture.c
index c14e600d3f..f6671edd51 100644
--- a/src/misc/picture.c
+++ b/src/misc/picture.c
@@ -38,6 +38,8 @@
 #include <vlc_image.h>
 #include <vlc_block.h>
 
+#define PICTURE_SW_SIZE_MAX (1<<28) /* 256MB: 8K * 8K * 4*/
+
 /**
  * Allocate a new picture in the heap.
  *
@@ -62,6 +64,12 @@ static int AllocatePicture( picture_t *p_pic )
         i_bytes += p->i_pitch * p->i_lines;
     }
 
+    if( i_bytes >= PICTURE_SW_SIZE_MAX )
+    {
+        p_pic->i_planes = 0;
+        return VLC_ENOMEM;
+    }
+
     uint8_t *p_data = aligned_alloc( 16, i_bytes );
     if( i_bytes > 0 && p_data == NULL )
     {



More information about the vlc-commits mailing list