JP2: limits the maximum number of channels to the global value defined

This commit is contained in:
Mirco Miranda
2026-06-22 08:36:49 +02:00
parent a5c6239138
commit 18322b0659

View File

@@ -186,7 +186,7 @@ public:
bool isImageValid(const opj_image_t *i) const
{
return i && i->comps && i->numcomps > 0 && i->numcomps < 256;
return i && i->comps && i->numcomps > 0 && i->numcomps <= KIF_MAX_IMAGE_CHANNELS;
}
void enableThreads(opj_codec_t *codec) const
@@ -347,11 +347,16 @@ public:
bool checkSizeLimits(qint32 width, qint32 height, qint32 nchannels) const
{
if (width > JP2_MAX_IMAGE_WIDTH || height > JP2_MAX_IMAGE_HEIGHT || width < 1 || height < 1) {
if (width > JP2_MAX_IMAGE_WIDTH || height > JP2_MAX_IMAGE_HEIGHT) {
qCCritical(LOG_JP2PLUGIN) << "Maximum image size is limited to" << JP2_MAX_IMAGE_WIDTH << "x" << JP2_MAX_IMAGE_HEIGHT << "pixels";
return false;
}
if (width < 1 || height < 1) {
qCCritical(LOG_JP2PLUGIN) << "The image size" << width << "x" << height << "pixels is not valid";
return false;
}
if (qint64(width) * qint64(height) > JP2_MAX_IMAGE_PIXELS) {
qCCritical(LOG_JP2PLUGIN) << "Maximum image size is limited to" << JP2_MAX_IMAGE_PIXELS << "pixels";
return false;