]> rtime.felk.cvut.cz Git - frescor/ffmpeg.git/commitdiff
segfault fix
authormichael <michael@9553f0bf-9b14-0410-a0b8-cfaf0461ba5b>
Sun, 21 Aug 2005 15:44:59 +0000 (15:44 +0000)
committermichael <michael@9553f0bf-9b14-0410-a0b8-cfaf0461ba5b>
Sun, 21 Aug 2005 15:44:59 +0000 (15:44 +0000)
git-svn-id: file:///var/local/repositories/ffmpeg/trunk@4531 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b

libavcodec/pnm.c

index 30a65701699f42a9c54d689806943c083fe172d5..aae798bcaa25e60d4098c44f584d49d125fb4ae9 100644 (file)
@@ -198,6 +198,8 @@ static int pnm_decode_frame(AVCodecContext *avctx,
     do_read:
         ptr = p->data[0];
         linesize = p->linesize[0];
+        if(s->bytestream + n*avctx->height > s->bytestream_end)
+            return -1;
         for(i = 0; i < avctx->height; i++) {
             memcpy(ptr, s->bytestream, n);
             s->bytestream += n;
@@ -211,6 +213,8 @@ static int pnm_decode_frame(AVCodecContext *avctx,
             n = avctx->width;
             ptr = p->data[0];
             linesize = p->linesize[0];
+            if(s->bytestream + n*avctx->height*3/2 > s->bytestream_end)
+                return -1;
             for(i = 0; i < avctx->height; i++) {
                 memcpy(ptr, s->bytestream, n);
                 s->bytestream += n;
@@ -233,6 +237,8 @@ static int pnm_decode_frame(AVCodecContext *avctx,
     case PIX_FMT_RGBA32:
         ptr = p->data[0];
         linesize = p->linesize[0];
+        if(s->bytestream + avctx->width*avctx->height*4 > s->bytestream_end)
+            return -1;
         for(i = 0; i < avctx->height; i++) {
             int j, r, g, b, a;