summaryrefslogtreecommitdiff
path: root/libavcodec/ansi.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2017-05-29 14:07:33 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2017-05-29 14:08:07 +0200
commite091b9b3c7859030f2896ca2ae96faa3afc694a1 (patch)
treeab88cdd37f9b21658fbfe03c3b1f310fae08ace8 /libavcodec/ansi.c
parentc49fa2a51452eeba0cf2c14ce999ddeadf69aa4f (diff)
downloadffmpeg-e091b9b3c7859030f2896ca2ae96faa3afc694a1.tar.gz
avcodec/ansi: Fix frame memleak
Fixes: 1892/clusterfuzz-testcase-minimized-4519341733183488 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec/ansi.c')
-rw-r--r--libavcodec/ansi.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/libavcodec/ansi.c b/libavcodec/ansi.c
index 3c82dcd338..f1fafab771 100644
--- a/libavcodec/ansi.c
+++ b/libavcodec/ansi.c
@@ -80,10 +80,6 @@ static av_cold int decode_init(AVCodecContext *avctx)
AnsiContext *s = avctx->priv_data;
avctx->pix_fmt = AV_PIX_FMT_PAL8;
- s->frame = av_frame_alloc();
- if (!s->frame)
- return AVERROR(ENOMEM);
-
/* defaults */
s->font = avpriv_vga16_font;
s->font_height = 16;
@@ -98,6 +94,11 @@ static av_cold int decode_init(AVCodecContext *avctx)
av_log(avctx, AV_LOG_ERROR, "Invalid dimensions %d %d\n", avctx->width, avctx->height);
return AVERROR(EINVAL);
}
+
+ s->frame = av_frame_alloc();
+ if (!s->frame)
+ return AVERROR(ENOMEM);
+
return 0;
}