summaryrefslogtreecommitdiff
path: root/libavcodec/kmvc.c
diff options
context:
space:
mode:
Diffstat (limited to 'libavcodec/kmvc.c')
-rw-r--r--libavcodec/kmvc.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/libavcodec/kmvc.c b/libavcodec/kmvc.c
index 9c98badbde..6d5af5d657 100644
--- a/libavcodec/kmvc.c
+++ b/libavcodec/kmvc.c
@@ -33,6 +33,7 @@
#define KMVC_KEYFRAME 0x80
#define KMVC_PALETTE 0x40
#define KMVC_METHOD 0x0F
+#define MAX_PALSIZE 256
/*
* Decoder context
@@ -43,7 +44,7 @@ typedef struct KmvcContext {
int setpal;
int palsize;
- uint32_t pal[256];
+ uint32_t pal[MAX_PALSIZE];
uint8_t *cur, *prev;
uint8_t *frm0, *frm1;
GetByteContext g;
@@ -376,14 +377,15 @@ static av_cold int decode_init(AVCodecContext * avctx)
}
if (avctx->extradata_size < 12) {
- av_log(NULL, 0, "Extradata missing, decoding may not work properly...\n");
+ av_log(avctx, AV_LOG_WARNING,
+ "Extradata missing, decoding may not work properly...\n");
c->palsize = 127;
} else {
c->palsize = AV_RL16(avctx->extradata + 10);
- if (c->palsize > 255U) {
+ if (c->palsize >= (unsigned)MAX_PALSIZE) {
c->palsize = 127;
- av_log(NULL, AV_LOG_ERROR, "palsize too big\n");
- return -1;
+ av_log(avctx, AV_LOG_ERROR, "KMVC palette too large\n");
+ return AVERROR_INVALIDDATA;
}
}