Skip to content
Snippets Groups Projects
Commit 3132999f authored by Michael Niedermayer's avatar Michael Niedermayer
Browse files

j2kdec: Check for interger overflow in tile array allocation

parent 628c9dcc
No related branches found
No related tags found
No related merge requests found
...@@ -238,6 +238,9 @@ static int get_siz(J2kDecoderContext *s) ...@@ -238,6 +238,9 @@ static int get_siz(J2kDecoderContext *s)
s->numXtiles = ff_j2k_ceildiv(s->width - s->tile_offset_x, s->tile_width); s->numXtiles = ff_j2k_ceildiv(s->width - s->tile_offset_x, s->tile_width);
s->numYtiles = ff_j2k_ceildiv(s->height - s->tile_offset_y, s->tile_height); s->numYtiles = ff_j2k_ceildiv(s->height - s->tile_offset_y, s->tile_height);
if(s->numXtiles * (uint64_t)s->numYtiles > INT_MAX/sizeof(J2kTile))
return AVERROR(EINVAL);
s->tile = av_mallocz(s->numXtiles * s->numYtiles * sizeof(J2kTile)); s->tile = av_mallocz(s->numXtiles * s->numYtiles * sizeof(J2kTile));
if (!s->tile) if (!s->tile)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment