changeset 2839:b857807dfe30 libavcodec

segfault fix
author michael
date Sun, 21 Aug 2005 15:44:59 +0000
parents 5e0c3833d208
children 22eec5a1b043
files pnm.c
diffstat 1 files changed, 6 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/pnm.c	Tue Aug 16 07:53:03 2005 +0000
+++ b/pnm.c	Sun Aug 21 15:44:59 2005 +0000
@@ -198,6 +198,8 @@
     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 @@
             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 @@
     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;