summaryrefslogtreecommitdiff
path: root/libavcodec/flicvideo.c
diff options
context:
space:
mode:
authorCarl Eugen Hoyos <cehoyos@ag.or.at>2011-11-09 14:04:22 +0100
committerAnton Khirnov <anton@khirnov.net>2011-11-26 08:36:16 +0100
commit1484b5dec5e05c11a2e8619d8838b3d276984cb7 (patch)
tree6b4d6cd493aa8b82111ed37b1205c3a337ede126 /libavcodec/flicvideo.c
parent5ace144fe0b7519c389d3ddcdcf7082b4e89b0df (diff)
flicvideo: check extradata_size before accessing extradata.
Signed-off-by: Anton Khirnov <anton@khirnov.net>
Diffstat (limited to 'libavcodec/flicvideo.c')
-rw-r--r--libavcodec/flicvideo.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/libavcodec/flicvideo.c b/libavcodec/flicvideo.c
index a78fe5e077..8e8a813258 100644
--- a/libavcodec/flicvideo.c
+++ b/libavcodec/flicvideo.c
@@ -81,6 +81,12 @@ static av_cold int flic_decode_init(AVCodecContext *avctx)
unsigned char *fli_header = (unsigned char *)avctx->extradata;
int depth;
+ if (avctx->extradata_size != 12 &&
+ avctx->extradata_size != 128) {
+ av_log(avctx, AV_LOG_ERROR, "Expected extradata of 12 or 128 bytes\n");
+ return AVERROR_INVALIDDATA;
+ }
+
s->avctx = avctx;
s->fli_type = AV_RL16(&fli_header[4]); /* Might be overridden if a Magic Carpet FLC */
@@ -90,9 +96,6 @@ static av_cold int flic_decode_init(AVCodecContext *avctx)
/* special case for magic carpet FLIs */
s->fli_type = FLC_MAGIC_CARPET_SYNTHETIC_TYPE_CODE;
depth = 8;
- } else if (s->avctx->extradata_size != 128) {
- av_log(avctx, AV_LOG_ERROR, "Expected extradata of 12 or 128 bytes\n");
- return -1;
} else {
depth = AV_RL16(&fli_header[12]);
}