diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2021-08-04 10:53:02 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2021-08-06 13:50:39 +0200 |
commit | 71334c324e702c434d446e5fc329294c97b8516d (patch) | |
tree | a05fa52a68bedbb05d49abc08d728cd96d2d6baf /src/gui/image | |
parent | 066dd1cdc0660d2e47bbcbad3c119d7029e08ecc (diff) |
QXpmHandler: actually limit characters-per-pixel to four
The following code assumed, and all comments indicated, that the cpp
variable was limited to a max of 4. Yet, as coded, cpp could be five,
in which case the XPM would be corrupt, as the header suggested five
characters-per-pixel while the data was formatted in only four.
Add a warning and error out when we encounter this situation.
[ChangeLog][QtGui][QImage] Instead of writing a corrupt file, rejects
to write XPM files with more than 64^4 colors (more than four
characters per pixel) now.
Pick-to: 6.2 6.1 5.15 5.12
Change-Id: I458873cf7d179ab2e2dacd4c17dc837d640591a9
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/gui/image')
-rw-r--r-- | src/gui/image/qxpmhandler.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/gui/image/qxpmhandler.cpp b/src/gui/image/qxpmhandler.cpp index 501f3067fc..22bfab684c 100644 --- a/src/gui/image/qxpmhandler.cpp +++ b/src/gui/image/qxpmhandler.cpp @@ -1145,8 +1145,11 @@ static bool write_xpm_image(const QImage &sourceImage, QIODevice *device, const ++cpp; // limit to 4 characters per pixel // 64^4 colors is enough for a 4096x4096 image - if (cpp > 4) - break; + if (cpp > 4) { + qCWarning(lcImageIo, "Qt does not support writing XPM images with more than " + "64^4 colors (requested: %d colors).", ncolors); + return false; + } } // write header |