[FFmpeg-devel] [PATCHv2] ffplay: detect when the created overlay buffers are not valid for the wanted overlay height

Marton Balint cus at passwd.hu
Sat Jun 1 02:25:58 CEST 2013


Fixes cases when the picture height was bigger than the maximum supported
overlay height...

V2 fixes a possible null pointer dereference...

Signed-off-by: Marton Balint <cus at passwd.hu>
---
 ffplay.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/ffplay.c b/ffplay.c
index ee9d6b2..12330ca 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -1490,6 +1490,7 @@ display:
 static void alloc_picture(VideoState *is)
 {
     VideoPicture *vp;
+    int64_t bufferdiff;
 
     vp = &is->pictq[is->pictq_windex];
 
@@ -1501,7 +1502,8 @@ static void alloc_picture(VideoState *is)
     vp->bmp = SDL_CreateYUVOverlay(vp->width, vp->height,
                                    SDL_YV12_OVERLAY,
                                    screen);
-    if (!vp->bmp || vp->bmp->pitches[0] < vp->width) {
+    bufferdiff = vp->bmp ? FFMAX(vp->bmp->pixels[0], vp->bmp->pixels[1]) - FFMIN(vp->bmp->pixels[0], vp->bmp->pixels[1]) : 0;
+    if (!vp->bmp || vp->bmp->pitches[0] < vp->width || bufferdiff < vp->height * vp->bmp->pitches[0]) {
         /* SDL allocates a buffer smaller than requested if the video
          * overlay hardware is unable to support the requested size. */
         fprintf(stderr, "Error: the video system does not support an image\n"
-- 
1.8.1.4



More information about the ffmpeg-devel mailing list