mirror of
https://invent.kde.org/frameworks/kimageformats.git
synced 2025-07-18 03:54:18 -04:00
Fix image allocation with Qt 6
To make the plugins fail to allocate if the image size is greater than QImageReader::allocationLimit() it is necessary to allocate the image with QImageIOHandler::allocateImage(). Note that not all plugins have been changed and some others are not tested in the CI (maybe due to missing libraries). PS: the following message is printed by QImageIOHandler::allocateImage() if the size is exceeded: "qt.gui.imageio: QImageIOHandler: Rejecting image as it exceeds the current allocation limit of XXX megabytes"
This commit is contained in:
committed by
Albert Astals Cid
parent
dfbc6e0f8c
commit
feb6d9b20f
@ -17,6 +17,7 @@
|
||||
*/
|
||||
|
||||
#include "tga_p.h"
|
||||
#include "util_p.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
@ -172,7 +173,7 @@ struct TgaHeaderInfo {
|
||||
static bool LoadTGA(QDataStream &s, const TgaHeader &tga, QImage &img)
|
||||
{
|
||||
// Create image.
|
||||
img = QImage(tga.width, tga.height, QImage::Format_RGB32);
|
||||
img = imageAlloc(tga.width, tga.height, QImage::Format_RGB32);
|
||||
if (img.isNull()) {
|
||||
qWarning() << "Failed to allocate image, invalid dimensions?" << QSize(tga.width, tga.height);
|
||||
return false;
|
||||
@ -184,7 +185,7 @@ static bool LoadTGA(QDataStream &s, const TgaHeader &tga, QImage &img)
|
||||
const int numAlphaBits = tga.flags & 0xf;
|
||||
// However alpha exists only in the 32 bit format.
|
||||
if ((tga.pixel_size == 32) && (tga.flags & 0xf)) {
|
||||
img = QImage(tga.width, tga.height, QImage::Format_ARGB32);
|
||||
img = imageAlloc(tga.width, tga.height, QImage::Format_ARGB32);
|
||||
if (img.isNull()) {
|
||||
qWarning() << "Failed to allocate image, invalid dimensions?" << QSize(tga.width, tga.height);
|
||||
return false;
|
||||
|
Reference in New Issue
Block a user