Commit a4d3cf10 authored by Michael Niedermayer's avatar Michael Niedermayer

avcodec/diracdec: Check slices malloc and propagate error code

Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent 0b52bdfb
......@@ -772,7 +772,7 @@ static int decode_lowdelay_slice(AVCodecContext *avctx, void *arg)
* Dirac Specification ->
* 13.5.1 low_delay_transform_data()
*/
static void decode_lowdelay(DiracContext *s)
static int decode_lowdelay(DiracContext *s)
{
AVCodecContext *avctx = s->avctx;
int slice_x, slice_y, bytes, bufsize;
......@@ -781,6 +781,8 @@ static void decode_lowdelay(DiracContext *s)
int slice_num = 0;
slices = av_mallocz_array(s->lowdelay.num_x, s->lowdelay.num_y * sizeof(struct lowdelay_slice));
if (!slices)
return AVERROR(ENOMEM);
align_get_bits(&s->gb);
/*[DIRAC_STD] 13.5.2 Slices. slice(sx,sy) */
......@@ -808,6 +810,7 @@ static void decode_lowdelay(DiracContext *s)
intra_dc_prediction(&s->plane[1].band[0][0]); /* [DIRAC_STD] 13.3 intra_dc_prediction() */
intra_dc_prediction(&s->plane[2].band[0][0]); /* [DIRAC_STD] 13.3 intra_dc_prediction() */
av_free(slices);
return 0;
}
static void init_planes(DiracContext *s)
......@@ -1590,6 +1593,7 @@ static int dirac_decode_frame_internal(DiracContext *s)
{
DWTContext d;
int y, i, comp, dsty;
int ret;
if (s->low_delay) {
/* [DIRAC_STD] 13.5.1 low_delay_transform_data() */
......@@ -1597,8 +1601,10 @@ static int dirac_decode_frame_internal(DiracContext *s)
Plane *p = &s->plane[comp];
memset(p->idwt_buf, 0, p->idwt_stride * p->idwt_height * sizeof(IDWTELEM));
}
if (!s->zero_res)
decode_lowdelay(s);
if (!s->zero_res) {
if ((ret = decode_lowdelay(s)) < 0)
return ret;
}
}
for (comp = 0; comp < 3; comp++) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment