diff options
Diffstat (limited to 'src/gui/image')
-rw-r--r-- | src/gui/image/qicon.cpp | 7 | ||||
-rw-r--r-- | src/gui/image/qimageiohandler.h | 2 | ||||
-rw-r--r-- | src/gui/image/qimagereader.cpp | 2 | ||||
-rw-r--r-- | src/gui/image/qppmhandler.cpp | 14 |
4 files changed, 16 insertions, 9 deletions
diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp index c362d0dc3f..285cdf790a 100644 --- a/src/gui/image/qicon.cpp +++ b/src/gui/image/qicon.cpp @@ -1080,11 +1080,12 @@ void QIcon::addFile(const QString &fileName, const QSize &size, Mode mode, State if (!d) { QFileInfo info(fileName); - QIconEngine *engine = iconEngineFromSuffix(fileName, info.suffix()); + QString suffix = info.suffix(); #if QT_CONFIG(mimetype) - if (!engine) - engine = iconEngineFromSuffix(fileName, QMimeDatabase().mimeTypeForFile(info).preferredSuffix()); + if (suffix.isEmpty()) + suffix = QMimeDatabase().mimeTypeForFile(info).preferredSuffix(); // determination from contents #endif // mimetype + QIconEngine *engine = iconEngineFromSuffix(fileName, suffix); d = new QIconPrivate(engine ? engine : new QPixmapIconEngine); } diff --git a/src/gui/image/qimageiohandler.h b/src/gui/image/qimageiohandler.h index 35984dd6a5..990df96534 100644 --- a/src/gui/image/qimageiohandler.h +++ b/src/gui/image/qimageiohandler.h @@ -141,7 +141,7 @@ class Q_GUI_EXPORT QImageIOPlugin : public QObject Q_OBJECT public: explicit QImageIOPlugin(QObject *parent = nullptr); - virtual ~QImageIOPlugin(); + ~QImageIOPlugin(); enum Capability { CanRead = 0x1, diff --git a/src/gui/image/qimagereader.cpp b/src/gui/image/qimagereader.cpp index 0fb1d808e5..3f1297c81a 100644 --- a/src/gui/image/qimagereader.cpp +++ b/src/gui/image/qimagereader.cpp @@ -526,7 +526,7 @@ bool QImageReaderPrivate::initHandler() // Try the most probable extension first int currentFormatIndex = extensions.indexOf(format.toLower()); if (currentFormatIndex > 0) - extensions.swap(0, currentFormatIndex); + extensions.swapItemsAt(0, currentFormatIndex); } int currentExtension = 0; diff --git a/src/gui/image/qppmhandler.cpp b/src/gui/image/qppmhandler.cpp index 53e3fa293d..bfde0aa76e 100644 --- a/src/gui/image/qppmhandler.cpp +++ b/src/gui/image/qppmhandler.cpp @@ -68,13 +68,19 @@ static int read_pbm_int(QIODevice *d) char c; int val = -1; bool digit; + bool hasOverflow = false; for (;;) { if (!d->getChar(&c)) // end of file break; digit = isdigit((uchar) c); if (val != -1) { if (digit) { - val = 10*val + c - '0'; + const int cValue = c - '0'; + if (val <= (INT_MAX - cValue) / 10) { + val = 10*val + cValue; + } else { + hasOverflow = true; + } continue; } else { if (c == '#') // comment @@ -91,7 +97,7 @@ static int read_pbm_int(QIODevice *d) else break; } - return val; + return hasOverflow ? -1 : val; } static bool read_pbm_header(QIODevice *device, char& type, int& w, int& h, int& mcc) @@ -123,7 +129,7 @@ static bool read_pbm_header(QIODevice *device, char& type, int& w, int& h, int& static inline QRgb scale_pbm_color(quint16 mx, quint16 rv, quint16 gv, quint16 bv) { - return QRgba64::fromRgba64((rv * 0xffff) / mx, (gv * 0xffff) / mx, (bv * 0xffff) / mx, 0xffff).toArgb32(); + return QRgba64::fromRgba64((rv * 0xffffu) / mx, (gv * 0xffffu) / mx, (bv * 0xffffu) / mx, 0xffff).toArgb32(); } static bool read_pbm_body(QIODevice *device, char type, int w, int h, int mcc, QImage *outImage) @@ -252,7 +258,7 @@ static bool read_pbm_body(QIODevice *device, char type, int w, int h, int mcc, Q } } else { while (n--) { - *p++ = read_pbm_int(device) * 255 / mcc; + *p++ = (read_pbm_int(device) & 0xffff) * 255 / mcc; } } } else { // 32 bits |