Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2016-01-27 19:13:10 +0300
committerMichael Niedermayer <michael@niedermayer.cc>2016-01-27 19:18:00 +0300
commit0aada30510d809bccfd539a90ea37b61188f2cb4 (patch)
tree4ff54e66af7fee7111aa7659791f2978496e568b
parent75a7565bcb69701823a922c6b2becb35fbd7983f (diff)
avcodec/jpeg2000dec: More completely check cdef
Fixes out of array read Fixes: j2k-poc.bin Found-by: Lucas Leong <wmliang.tw@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavcodec/jpeg2000dec.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index 849b0f7262..c13670e6d6 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -1766,11 +1766,15 @@ static int jpeg2000_decode_tile(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile,
if (tile->codsty[0].mct)
mct_decode(s, tile);
- if (s->cdef[0] < 0) {
- for (x = 0; x < s->ncomponents; x++)
- s->cdef[x] = x + 1;
- if ((s->ncomponents & 1) == 0)
- s->cdef[s->ncomponents-1] = 0;
+ for (x = 0; x < s->ncomponents; x++) {
+ if (s->cdef[x] < 0) {
+ for (x = 0; x < s->ncomponents; x++) {
+ s->cdef[x] = x + 1;
+ }
+ if ((s->ncomponents & 1) == 0)
+ s->cdef[s->ncomponents-1] = 0;
+ break;
+ }
}
if (s->precision <= 8) {