Skip to content

Commit

Permalink
Added check for the number of layers to the jp2 coder.
Browse files Browse the repository at this point in the history
  • Loading branch information
dlemstra committed Apr 30, 2024
1 parent 87e13b5 commit a056a15
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions coders/jp2.c
Expand Up @@ -283,6 +283,9 @@ static Image *ReadJP2Image(const ImageInfo *image_info,ExceptionInfo *exception)
opj_codec_t
*jp2_codec;

opj_codestream_info_v2_t
*jp2_codestream_info;

opj_dparameters_t
parameters;

Expand Down Expand Up @@ -363,6 +366,14 @@ static Image *ReadJP2Image(const ImageInfo *image_info,ExceptionInfo *exception)
opj_destroy_codec(jp2_codec);
ThrowReaderException(DelegateError,"UnableToDecodeImageFile");
}
jp2_codestream_info=opj_get_cstr_info(jp2_codec);
if (AcquireMagickResource(ListLengthResource,(MagickSizeType)
jp2_codestream_info->m_default_tile_info.numlayers) == MagickFalse)
{
opj_stream_destroy(jp2_stream);
opj_destroy_codec(jp2_codec);
ThrowReaderException(ResourceLimitError,"ListLengthExceedsLimit");
}
jp2_status=OPJ_TRUE;
if ((AcquireMagickResource(WidthResource,(size_t) jp2_image->comps[0].w) == MagickFalse) ||
(AcquireMagickResource(WidthResource,(size_t) jp2_image->x1) == MagickFalse) ||
Expand Down

0 comments on commit a056a15

Please sign in to comment.