[vlc-commits] dxva2: check number of surfaces to allocate is not larger than the upper bound

Felix Abecassis git at videolan.org
Wed Mar 5 11:35:21 CET 2014


vlc/vlc-2.1 | branch: master | Felix Abecassis <felix.abecassis at gmail.com> | Tue Mar  4 15:22:01 2014 +0100| [a8d60e4cb34d421d84c73512ec2531d5f8b8b825] | committer: Jean-Baptiste Kempf

dxva2: check number of surfaces to allocate is not larger than the upper bound

Signed-off-by: Rémi Denis-Courmont <remi at remlab.net>
(cherry picked from commit fe573d25f0c5c640e822671e561013ae8f3a069e)
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

 modules/codec/avcodec/dxva2.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/modules/codec/avcodec/dxva2.c b/modules/codec/avcodec/dxva2.c
index bde6e4c..a589696 100644
--- a/modules/codec/avcodec/dxva2.c
+++ b/modules/codec/avcodec/dxva2.c
@@ -862,14 +862,18 @@ static int DxCreateVideoDecoder(vlc_va_dxva2_t *va,
     /* Allocates all surfaces needed for the decoder */
     va->surface_width  = (fmt->i_width  + 15) & ~15;
     va->surface_height = (fmt->i_height + 15) & ~15;
+    int surface_count;
     switch (codec_id) {
     case AV_CODEC_ID_H264:
-        va->surface_count = 16 + 1;
+        surface_count = 16 + 1;
         break;
     default:
-        va->surface_count = 2 + 1;
+        surface_count = 2 + 1;
         break;
     }
+    if (surface_count > VA_DXVA2_MAX_SURFACE_COUNT)
+        return VLC_EGENERIC;
+    va->surface_count = surface_count;
     if (FAILED(IDirectXVideoDecoderService_CreateSurface(va->vs,
                                                          va->surface_width,
                                                          va->surface_height,



More information about the vlc-commits mailing list