Compare commits

..

26 Commits

Author SHA1 Message Date
d1136c4bac GIT_SILENT Upgrade ECM and KF5 version requirements for 5.72.0 release. 2020-07-04 09:51:54 +00:00
a446331a5e GIT_SILENT Upgrade ECM and KF5 version requirements for 5.71.0 release. 2020-06-06 19:34:48 +00:00
37be13e3a4 GIT_SILENT increase KF_DISABLE_DEPRECATED_BEFORE_AND_AT 2020-06-05 10:40:11 +02:00
51d0b2ad86 GIT_SILENT: we don't use phabricator anymore 2020-05-19 07:13:43 +02:00
8562ce18f1 Add some sanity and bounds checking
Since QImage does sanity checking for overflows and stuff wrt.
dimensions and depth, check for QImage::isNull() as early as possible to
see if there's some funky business going on.

Also tried to add some checks wherever we wrote to "raw" memory.

Unit tests pass, and tested converting some files from
https://samples.ffmpeg.org/image-samples/ to pngs, and that seemed to
work.

Reviewed By: aacid

Differential Revision: https://phabricator.kde.org/D24367
2020-05-10 18:06:56 +02:00
f5b26cc9f9 GIT_SILENT increase KF_DISABLE_DEPRECATED_BEFORE_AND_AT 2020-05-10 00:38:45 +02:00
105d0fab46 GIT_SILENT Upgrade ECM and KF5 version requirements for 5.70.0 release. 2020-05-02 21:58:20 +00:00
497b6b81bd Fix build on Windows.
We added our own implementation of rand_r to make sure we use the same
as Gimp, and to make Windows work. But we need to actually use it
everywhere.

Discussion in Differential:

Differential Revision: https://phabricator.kde.org/D25267
2020-04-15 09:46:54 +02:00
c60e77c048 Add support for modern Gimp images/XCF files
We now support up to and including version 11 of the XCF format, earlier
it only supported version 1 (from 1997, according to the XCF spec).

Biggest difference seems to be that they changed to 64bit for offsets
from version 11 and upwards, otherwise it's mostly just newer enum
values and theoretically major stuff that we don't really need to care
about to get a thumbnail (e. g. linear vs. perceptual RGB).

We still don't support all features, but now it handles that more
gracefully and should at least create thumbnails that are usable. It
should also be easier to update in the future if/when there comes new
versions.

Also added a test file created with the latest version of Gimp
(2.10.18).

Reviewed By: aacid

Differential Revision: https://phabricator.kde.org/D25937
2020-04-13 14:52:33 +02:00
f089e860e0 GIT_SILENT Upgrade ECM and KF5 version requirements for 5.69.0 release. 2020-04-04 22:35:32 +00:00
551e7d44a8 Port the HDR plugin from sscanf() to QRegularExpression. Fixes FreeBSD. 2020-03-29 13:04:34 +02:00
232075f92e Port HDR plugin to qCDebug, to debug CI failure on FreeBSD
NO_CHANGELOG
2020-03-29 12:14:13 +02:00
1d12b345f9 GIT_SILENT add missing newline 2020-03-29 01:06:42 +01:00
becd7aff3a autotests: print QImageReader::supportedImageFormats, to debug CI failures 2020-03-29 00:47:47 +01:00
52fbe1863b GIT_SILENT increase KF_DISABLE_DEPRECATED_BEFORE_AND_AT 2020-03-25 00:54:05 +01:00
203f459536 GIT_SILENT Upgrade ECM and KF5 version requirements for 5.68.0 release. 2020-03-07 08:52:35 +00:00
693bb34b69 GIT_SILENT: qtcreator created .cmake/ repo. 2020-02-12 07:12:24 +01:00
5c66570b9e GIT_SILENT increase KF_DISABLE_DEPRECATED_BEFORE_AND_AT 2020-02-09 20:26:37 +01:00
cba2328ae6 GIT_SILENT Upgrade ECM and KF5 version requirements for 5.67.0 release. 2020-02-01 09:04:07 +00:00
961465a311 GIT_SILENT Bump KF5 deprecation level to 5.66 2020-01-12 12:46:21 +01:00
b7cd5cddc1 GIT_SILENT Upgrade ECM and KF5 version requirements for 5.66.0 release. 2020-01-03 23:12:09 +00:00
ce56b97ee7 GIT_SILENT Upgrade Qt5 version requirement to 5.12.0. 2019-12-21 12:34:54 +01:00
500ce13265 Update the obsolete projects.kde.org URL
Use the generic redirect commits.kde.org.

Change discussed on the kde-frameworks-devel list:
https://mail.kde.org/pipermail/kde-frameworks-devel/2019-November/097564.html
2019-12-15 22:42:38 +01:00
f03739f222 pic: Fix Invalid-enum-value undefined behaviour
Summary:
Instead of directly casting the quint8 to PicChannelEncoding we just store the quint8
and compare it to the possible PicChannelEncoding values when needed

oss-fuzz/19344

Reviewers: dfaure

Reviewed By: dfaure

Subscribers: dfaure, security-team, kde-frameworks-devel

Tags: #frameworks

Differential Revision: https://phabricator.kde.org/D25937
2019-12-14 21:05:02 +01:00
69effbf9f5 GIT_SILENT Bump KF5 deprecation level to 5.65 2019-12-14 12:22:02 +01:00
f06cf300f1 GIT_SILENT Bump KF5 deprecation level to 5.64 2019-12-14 11:45:23 +01:00
17 changed files with 794 additions and 239 deletions

View File

@ -1,3 +0,0 @@
{
"phabricator.uri" : "https://phabricator.kde.org/"
}

1
.gitignore vendored
View File

@ -19,3 +19,4 @@ random_seed
/build*/
CMakeLists.txt.user*
*.unc-backup*
.cmake/

View File

@ -2,9 +2,11 @@ cmake_minimum_required(VERSION 3.5)
project(KImageFormats)
set (CMAKE_CXX_STANDARD 14)
include(FeatureSummary)
find_package(ECM 5.65.0 NO_MODULE)
set_package_properties(ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake Modules." URL "https://projects.kde.org/projects/kdesupport/extra-cmake-modules")
find_package(ECM 5.72.0 NO_MODULE)
set_package_properties(ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake Modules." URL "https://commits.kde.org/extra-cmake-modules")
feature_summary(WHAT REQUIRED_PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKAGES)
@ -17,7 +19,7 @@ include(KDECMakeSettings)
include(CheckIncludeFiles)
set(REQUIRED_QT_VERSION 5.11.0)
set(REQUIRED_QT_VERSION 5.12.0)
find_package(Qt5Gui ${REQUIRED_QT_VERSION} REQUIRED NO_MODULE)
find_package(KF5Archive)
@ -49,7 +51,7 @@ add_definitions(-DQT_NO_FOREACH)
# 050d00 (5.13) triggers a BIC in qimageiohandler.h, in Qt 5.13, so do not enable that until we can require 5.14
# https://codereview.qt-project.org/c/qt/qtbase/+/279215
add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x050c00)
add_definitions(-DKF_DISABLE_DEPRECATED_BEFORE_AND_AT=0x053f00)
add_definitions(-DKF_DISABLE_DEPRECATED_BEFORE_AND_AT=0x054700)
add_subdirectory(src)
if (BUILD_TESTING)
add_subdirectory(autotests)

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 KiB

Binary file not shown.

View File

@ -127,6 +127,12 @@ int main(int argc, char ** argv)
<< "Starting basic read tests for "
<< suffix << " images *********\n";
const QList<QByteArray> formats = QImageReader::supportedImageFormats();
QStringList formatStrings;
formatStrings.reserve(formats.size());
std::transform(formats.begin(), formats.end(), std::back_inserter(formatStrings), [](const QByteArray &format) { return QString(format); });
QTextStream(stdout) << "QImageReader::supportedImageFormats: " << formatStrings.join(", ") << "\n";
const QFileInfoList lstImgDir = imgdir.entryInfoList();
for (const QFileInfo &fi : lstImgDir) {
int suffixPos = fi.filePath().count() - suffix.count();
@ -134,7 +140,7 @@ int main(int argc, char ** argv)
QString expfile = fi.filePath().replace(suffixPos, suffix.count(), QStringLiteral("png"));
QString expfilename = QFileInfo(expfile).fileName();
QImageReader inputReader(inputfile, format.constData());
QImageReader inputReader(inputfile, format);
QImageReader expReader(expfile, "png");
QImage inputImage;

View File

@ -17,7 +17,7 @@
#include <QCoreApplication>
// logging category for this framework, default: log stuff >= warning
Q_LOGGING_CATEGORY(EPSPLUGIN, "epsplugin", QtWarningMsg)
Q_LOGGING_CATEGORY(EPSPLUGIN, "kf5.kimageformats.epsplugin", QtWarningMsg)
//#define EPS_PERFORMANCE_DEBUG 1

View File

@ -172,17 +172,18 @@ bool EXRHandler::read(QImage *outImage)
width = dw.max.x - dw.min.x + 1;
height = dw.max.y - dw.min.y + 1;
QImage image(width, height, QImage::Format_RGB32);
if (image.isNull()) {
qWarning() << "Failed to allocate image, invalid size?" << QSize(width, height);
return false;
}
Imf::Array2D<Imf::Rgba> pixels;
pixels.resizeErase(height, width);
file.setFrameBuffer(&pixels[0][0] - dw.min.x - dw.min.y * width, 1, width);
file.readPixels(dw.min.y, dw.max.y);
QImage image(width, height, QImage::Format_RGB32);
if (image.isNull()) {
return false;
}
// somehow copy pixels into image
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {

View File

@ -56,16 +56,6 @@ typedef enum {
INDEXED
} GimpImageBaseType;
//! Type of individual layers in an XCF file.
typedef enum {
RGB_GIMAGE,
RGBA_GIMAGE,
GRAY_GIMAGE,
GRAYA_GIMAGE,
INDEXED_GIMAGE,
INDEXEDA_GIMAGE
} GimpImageType;
// From GIMP "libgimp/gimpenums.h" v2.4
@ -96,49 +86,6 @@ typedef enum {
GRAIN_MERGE_MODE
} LayerModeEffects;
// From GIMP "xcf.c" v1.2
//! Properties which can be stored in an XCF file.
typedef enum {
PROP_END = 0,
PROP_COLORMAP = 1,
PROP_ACTIVE_LAYER = 2,
PROP_ACTIVE_CHANNEL = 3,
PROP_SELECTION = 4,
PROP_FLOATING_SELECTION = 5,
PROP_OPACITY = 6,
PROP_MODE = 7,
PROP_VISIBLE = 8,
PROP_LINKED = 9,
PROP_PRESERVE_TRANSPARENCY = 10,
PROP_APPLY_MASK = 11,
PROP_EDIT_MASK = 12,
PROP_SHOW_MASK = 13,
PROP_SHOW_MASKED = 14,
PROP_OFFSETS = 15,
PROP_COLOR = 16,
PROP_COMPRESSION = 17,
PROP_GUIDES = 18,
PROP_RESOLUTION = 19,
PROP_TATTOO = 20,
PROP_PARASITES = 21,
PROP_UNIT = 22,
PROP_PATHS = 23,
PROP_USER_UNIT = 24,
MAX_SUPPORTED_PROPTYPE // should always be at the end so its value is last + 1
} PropType;
// From GIMP "xcf.c" v1.2
//! Compression type used in layer tiles.
typedef enum {
COMPRESS_NONE = 0,
COMPRESS_RLE = 1,
COMPRESS_ZLIB = 2,
COMPRESS_FRACTAL = 3 /* Unused. */
} CompressionType;
// From GIMP "paint_funcs.c" v1.2

View File

@ -12,11 +12,15 @@
#include <QImage>
#include <QDataStream>
#include <QLoggingCategory>
#include <QRegularExpressionMatch>
#include <QDebug>
typedef unsigned char uchar;
Q_LOGGING_CATEGORY(HDRPLUGIN, "kf5.kimageformats.hdrplugin", QtWarningMsg)
namespace // Private.
{
@ -95,6 +99,7 @@ static bool LoadHDR(QDataStream &s, const int width, const int height, QImage &i
// Create dst image.
img = QImage(width, height, QImage::Format_RGB32);
if (img.isNull()) {
qCDebug(HDRPLUGIN) << "Couldn't create image with size" << width << height << "and format RGB32";
return false;
}
@ -141,6 +146,7 @@ static bool LoadHDR(QDataStream &s, const int width, const int height, QImage &i
}
if ((image[2] << 8 | image[3]) != width) {
qCDebug(HDRPLUGIN) << "Line of pixels had width" << (image[2] << 8 | image[3]) << "instead of" << width;
return false;
}
@ -149,6 +155,7 @@ static bool LoadHDR(QDataStream &s, const int width, const int height, QImage &i
for (int j = 0; j < width;) {
s >> code;
if (s.atEnd()) {
qCDebug(HDRPLUGIN) << "Truncated HDR file";
return false;
}
if (code > 128) {
@ -182,39 +189,48 @@ static bool LoadHDR(QDataStream &s, const int width, const int height, QImage &i
bool HDRHandler::read(QImage *outImage)
{
int len;
char line[MAXLINE];
//bool validHeader = false;
bool validFormat = false;
QByteArray line(MAXLINE + 1, Qt::Uninitialized);
QByteArray format;
// Parse header
do {
len = device()->readLine(line, MAXLINE);
len = device()->readLine(line.data(), MAXLINE);
/*if (strcmp(line, "#?RADIANCE\n") == 0 || strcmp(line, "#?RGBE\n") == 0)
{
validHeader = true;
}*/
if (strcmp(line, "FORMAT=32-bit_rle_rgbe\n") == 0) {
validFormat = true;
if (line.startsWith("FORMAT=")) {
format = line.mid(7, len - 7 - 1 /*\n*/);
}
} while ((len > 0) && (line[0] != '\n'));
if (/*!validHeader ||*/ !validFormat) {
// qDebug() << "Unknown HDR format.";
if (format != "32-bit_rle_rgbe") {
qCDebug(HDRPLUGIN) << "Unknown HDR format:" << format;
return false;
}
device()->readLine(line, MAXLINE);
len = device()->readLine(line.data(), MAXLINE);
line.resize(len);
char s1[3], s2[3];
int width, height;
if (sscanf(line, "%2[+-XY] %d %2[+-XY] %d\n", s1, &height, s2, &width) != 4)
//if( sscanf(line, "-Y %d +X %d", &height, &width) < 2 )
{
// qDebug() << "Invalid HDR file.";
/*
TODO: handle flipping and rotation, as per the spec below
The single resolution line consists of 4 values, a X and Y label each followed by a numerical
integer value. The X and Y are immediately preceded by a sign which can be used to indicate
flipping, the order of the X and Y indicate rotation. The standard coordinate system for
Radiance images would have the following resolution string -Y N +X N. This indicates that the
vertical axis runs down the file and the X axis is to the right (imagining the image as a
rectangular block of data). A -X would indicate a horizontal flip of the image. A +Y would
indicate a vertical flip. If the X value appears before the Y value then that indicates that
the image is stored in column order rather than row order, that is, it is rotated by 90 degrees.
The reader can convince themselves that the 8 combinations cover all the possible image orientations
and rotations.
*/
QRegularExpression resolutionRegExp(QStringLiteral("([+\\-][XY]) ([0-9]+) ([+\\-][XY]) ([0-9]+)\n"));
QRegularExpressionMatch match = resolutionRegExp.match(QString::fromLatin1(line));
if (!match.hasMatch()) {
qCDebug(HDRPLUGIN) << "Invalid HDR file, the first line after the header didn't have the expected format:" << line;
return false;
}
const int width = match.captured(2).toInt();
const int height = match.captured(4).toInt();
QDataStream s(device());

View File

@ -253,8 +253,10 @@ static void readImage1(QImage &img, QDataStream &s, const PCXHEADER &header)
img = QImage(header.width(), header.height(), QImage::Format_Mono);
img.setColorCount(2);
if (img.isNull())
if (img.isNull()) {
qWarning() << "Failed to allocate image, invalid dimensions?" << QSize(header.width(), header.height());
return;
}
for (int y = 0; y < header.height(); ++y) {
if (s.atEnd()) {
@ -282,6 +284,10 @@ static void readImage4(QImage &img, QDataStream &s, const PCXHEADER &header)
img = QImage(header.width(), header.height(), QImage::Format_Indexed8);
img.setColorCount(16);
if (img.isNull()) {
qWarning() << "Failed to allocate image, invalid dimensions?" << QSize(header.width(), header.height());
return;
}
for (int y = 0; y < header.height(); ++y) {
if (s.atEnd()) {
@ -301,6 +307,9 @@ static void readImage4(QImage &img, QDataStream &s, const PCXHEADER &header)
}
uchar *p = img.scanLine(y);
if (!p) {
qWarning() << "Failed to get scanline for" << y << "might be out of bounds";
}
for (int x = 0; x < header.width(); ++x) {
p[ x ] = pixbuf[ x ];
}
@ -319,6 +328,11 @@ static void readImage8(QImage &img, QDataStream &s, const PCXHEADER &header)
img = QImage(header.width(), header.height(), QImage::Format_Indexed8);
img.setColorCount(256);
if (img.isNull()) {
qWarning() << "Failed to allocate image, invalid dimensions?" << QSize(header.width(), header.height());
return;
}
for (int y = 0; y < header.height(); ++y) {
if (s.atEnd()) {
img = QImage();
@ -360,6 +374,11 @@ static void readImage24(QImage &img, QDataStream &s, const PCXHEADER &header)
img = QImage(header.width(), header.height(), QImage::Format_RGB32);
if (img.isNull()) {
qWarning() << "Failed to allocate image, invalid dimensions?" << QSize(header.width(), header.height());
return;
}
for (int y = 0; y < header.height(); ++y) {
if (s.atEnd()) {
img = QImage();

View File

@ -130,9 +130,7 @@ static QDataStream &operator>> (QDataStream &s, QList<PicChannel> &channels)
PicChannel channel;
s >> chained;
s >> channel.size;
quint8 encoding;
s >> encoding;
channel.encoding = PicChannelEncoding(encoding);
s >> channel.encoding;
s >> channel.code;
channels << channel;
++count;
@ -255,6 +253,11 @@ bool SoftimagePICHandler::read(QImage *image)
}
QImage img(m_header.width, m_header.height, fmt);
if (img.isNull()) {
qDebug() << "Failed to allocate image, invalid dimensions?" << QSize(m_header.width, m_header.height) << fmt;
return false;
}
img.fill(qRgb(0,0,0));
for (int y = 0; y < m_header.height; y++) {
@ -364,6 +367,7 @@ bool SoftimagePICHandler::readHeader()
m_state = ReadHeader;
}
}
return m_state != Error;
}

View File

@ -119,7 +119,7 @@ struct PicHeader {
*/
struct PicChannel {
quint8 size; /**< Bits per component per pixel. */
PicChannelEncoding encoding; /**< How the channel's data is encoded. */
quint8 encoding; /**< How the channel's data is encoded. */
quint8 code; /**< Flag field to describe which components are encoded in
this channel. */

View File

@ -171,10 +171,20 @@ static bool LoadPSD(QDataStream &stream, const PSDHeader &header, QImage &img)
channel_num = 4;
}
img = QImage(header.width, header.height, fmt);
if (img.isNull()) {
qWarning() << "Failed to allocate image, invalid dimensions?" << QSize(header.width, header.height);
return false;
}
img.fill(qRgb(0,0,0));
const quint32 pixel_count = header.height * header.width;
// Verify this, as this is used to write into the memory of the QImage
if (pixel_count > img.sizeInBytes() / sizeof(QRgb)) {
qWarning() << "Invalid pixel count!" << pixel_count << "bytes available:" << img.sizeInBytes();
return false;
}
QRgb *image_data = reinterpret_cast<QRgb*>(img.bits());
if (!image_data) {
@ -276,6 +286,11 @@ bool PSDHandler::canRead(QIODevice *device)
char head[4];
qint64 readBytes = device->read(head, sizeof(head));
if (readBytes < 0) {
qWarning() << "Read failed" << device->errorString();
return false;
}
if (readBytes != sizeof(head)) {
if (device->isSequential()) {
while (readBytes > 0) {

View File

@ -313,6 +313,10 @@ bool SGIImage::readImage(QImage &img)
}
img = QImage(_xsize, _ysize, QImage::Format_RGB32);
if (img.isNull()) {
qWarning() << "Failed to allocate image, invalid dimensions?" << QSize(_xsize, _ysize);
return false;
}
if (_zsize == 0 )
return false;
@ -470,7 +474,14 @@ bool SGIImage::scanData(const QImage &img)
uint len;
for (y = 0; y < _ysize; y++) {
c = reinterpret_cast<const QRgb *>(img.scanLine(_ysize - y - 1));
const int yPos = _ysize - y - 1; // scanline doesn't do any sanity checking
if (yPos >= img.height()) {
qWarning() << "Failed to get scanline for" << yPos;
return false;
}
c = reinterpret_cast<const QRgb *>(img.scanLine(yPos));
for (x = 0; x < _xsize; x++) {
buf[x] = intensity(qRed(*c++));
}
@ -484,7 +495,13 @@ bool SGIImage::scanData(const QImage &img)
if (_zsize != 2) {
for (y = 0; y < _ysize; y++) {
c = reinterpret_cast<const QRgb *>(img.scanLine(_ysize - y - 1));
const int yPos = _ysize - y - 1;
if (yPos >= img.height()) {
qWarning() << "Failed to get scanline for" << yPos;
return false;
}
c = reinterpret_cast<const QRgb *>(img.scanLine(yPos));
for (x = 0; x < _xsize; x++) {
buf[x] = intensity(qGreen(*c++));
}
@ -493,7 +510,13 @@ bool SGIImage::scanData(const QImage &img)
}
for (y = 0; y < _ysize; y++) {
c = reinterpret_cast<const QRgb *>(img.scanLine(_ysize - y - 1));
const int yPos = _ysize - y - 1;
if (yPos >= img.height()) {
qWarning() << "Failed to get scanline for" << yPos;
return false;
}
c = reinterpret_cast<const QRgb *>(img.scanLine(yPos));
for (x = 0; x < _xsize; x++) {
buf[x] = intensity(qBlue(*c++));
}
@ -507,7 +530,13 @@ bool SGIImage::scanData(const QImage &img)
}
for (y = 0; y < _ysize; y++) {
c = reinterpret_cast<const QRgb *>(img.scanLine(_ysize - y - 1));
const int yPos = _ysize - y - 1;
if (yPos >= img.height()) {
qWarning() << "Failed to get scanline for" << yPos;
return false;
}
c = reinterpret_cast<const QRgb *>(img.scanLine(yPos));
for (x = 0; x < _xsize; x++) {
buf[x] = intensity(qAlpha(*c++));
}

View File

@ -178,6 +178,10 @@ static bool LoadTGA(QDataStream &s, const TgaHeader &tga, QImage &img)
{
// Create image.
img = QImage(tga.width, tga.height, QImage::Format_RGB32);
if (img.isNull()) {
qWarning() << "Failed to allocate image, invalid dimensions?" << QSize(tga.width, tga.height);
return false;
}
TgaHeaderInfo info(tga);
@ -186,6 +190,10 @@ static bool LoadTGA(QDataStream &s, const TgaHeader &tga, QImage &img)
// 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);
if (img.isNull()) {
qWarning() << "Failed to allocate image, invalid dimensions?" << QSize(tga.width, tga.height);
return false;
}
if (numAlphaBits > 8) {
return false;
@ -229,9 +237,10 @@ static bool LoadTGA(QDataStream &s, const TgaHeader &tga, QImage &img)
if (info.rle) {
// Decode image.
char *dst = (char *)image;
char *imgEnd = dst + size;
qint64 num = size;
while (num > 0) {
while (num > 0 && valid) {
if (s.atEnd()) {
valid = false;
break;
@ -257,6 +266,12 @@ static bool LoadTGA(QDataStream &s, const TgaHeader &tga, QImage &img)
memset(&pixel[dataRead], 0, pixel_size - dataRead);
}
do {
if (dst + pixel_size > imgEnd) {
qWarning() << "Trying to write out of bounds!" << ptrdiff_t(dst) << (ptrdiff_t(imgEnd) - ptrdiff_t(pixel_size));
valid = false;
break;
}
memcpy(dst, pixel, pixel_size);
dst += pixel_size;
} while (--count);
@ -268,8 +283,17 @@ static bool LoadTGA(QDataStream &s, const TgaHeader &tga, QImage &img)
free(image);
return false;
}
if ((uint)dataRead < count) {
memset(&dst[dataRead], 0, count - dataRead);
const size_t toCopy = count - dataRead;
if (&dst[dataRead] + toCopy > imgEnd) {
qWarning() << "Trying to write out of bounds!" << ptrdiff_t(image) << ptrdiff_t(&dst[dataRead]);;
valid = false;
break;
}
memset(&dst[dataRead], 0, toCopy);
}
dst += count;
}

File diff suppressed because it is too large Load Diff