aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/pnm.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2005-08-21 15:44:59 +0000
committerMichael Niedermayer <michaelni@gmx.at>2005-08-21 15:44:59 +0000
commit1cd89f276a0be52609904ea911a93cec78c92294 (patch)
tree52bf174fcb59ac88ded88508e88f8ce3a75a704b /libavcodec/pnm.c
parent2185824b1082e449587dfab5c649bd4f687c7e22 (diff)
downloadffmpeg-1cd89f276a0be52609904ea911a93cec78c92294.tar.gz
segfault fix
Originally committed as revision 4531 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/pnm.c')
-rw-r--r--libavcodec/pnm.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/libavcodec/pnm.c b/libavcodec/pnm.c
index 30a6570169..aae798bcaa 100644
--- a/libavcodec/pnm.c
+++ b/libavcodec/pnm.c
@@ -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;