# HG changeset patch # User michael # Date 1124639099 0 # Node ID b857807dfe3082f52623b21741d88c55e12273b9 # Parent 5e0c3833d208af3f87d8c7dae4d506521113f5f6 segfault fix diff -r 5e0c3833d208 -r b857807dfe30 pnm.c --- 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;