aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/zmbv.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-12-03 04:42:36 +0100
committerMichael Niedermayer <michaelni@gmx.at>2011-12-03 04:49:08 +0100
commit3eb6e14618a935d44f6664a1a7da4f1c482e845a (patch)
treeeef3af3a41870f2180326e46b3c0eb3bd7619d67 /libavcodec/zmbv.c
parent7a5eb40ea19c6edf279196287181b0c4f0548cb0 (diff)
downloadffmpeg-3eb6e14618a935d44f6664a1a7da4f1c482e845a.tar.gz
zmbv: Fix keyframe fault protextion.
Fixes zzuf -s467 -r0.001 cat samples/zmbv/wc2_001-partial.avi Bug-found-by: darkshikari Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/zmbv.c')
-rw-r--r--libavcodec/zmbv.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/libavcodec/zmbv.c b/libavcodec/zmbv.c
index 2694a4c3c8..39549c9083 100644
--- a/libavcodec/zmbv.c
+++ b/libavcodec/zmbv.c
@@ -415,6 +415,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac
c->flags = buf[0];
buf++; len--;
if(c->flags & ZMBV_KEYFRAME) {
+ void *decode_intra = NULL;
+ c->decode_intra= NULL;
hi_ver = buf[0];
lo_ver = buf[1];
c->comp = buf[2];
@@ -441,29 +443,28 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac
switch(c->fmt) {
case ZMBV_FMT_8BPP:
c->bpp = 8;
- c->decode_intra = zmbv_decode_intra;
+ decode_intra = zmbv_decode_intra;
c->decode_xor = zmbv_decode_xor_8;
break;
case ZMBV_FMT_15BPP:
case ZMBV_FMT_16BPP:
c->bpp = 16;
- c->decode_intra = zmbv_decode_intra;
+ decode_intra = zmbv_decode_intra;
c->decode_xor = zmbv_decode_xor_16;
break;
#ifdef ZMBV_ENABLE_24BPP
case ZMBV_FMT_24BPP:
c->bpp = 24;
- c->decode_intra = zmbv_decode_intra;
+ decode_intra = zmbv_decode_intra;
c->decode_xor = zmbv_decode_xor_24;
break;
#endif //ZMBV_ENABLE_24BPP
case ZMBV_FMT_32BPP:
c->bpp = 32;
- c->decode_intra = zmbv_decode_intra;
+ decode_intra = zmbv_decode_intra;
c->decode_xor = zmbv_decode_xor_32;
break;
default:
- c->decode_intra = NULL;
c->decode_xor = NULL;
av_log(avctx, AV_LOG_ERROR, "Unsupported (for now) format %i\n", c->fmt);
return -1;
@@ -479,6 +480,9 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac
c->prev = av_realloc(c->prev, avctx->width * avctx->height * (c->bpp / 8));
c->bx = (c->width + c->bw - 1) / c->bw;
c->by = (c->height+ c->bh - 1) / c->bh;
+ if(!c->cur || !c->prev)
+ return -1;
+ c->decode_intra= decode_intra;
}
if(c->decode_intra == NULL) {