summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2021-08-04 10:53:02 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-08-06 11:50:50 +0000
commite0c6f508491be3f3a6b10766efb33de7a5e996ce (patch)
treefc746918d9895c75e4ecade18b173f0f6ba4a09f /src
parent36760514a928b546ab5a944e60955361e6645d6a (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. 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> (cherry picked from commit 71334c324e702c434d446e5fc329294c97b8516d) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r--src/gui/image/qxpmhandler.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/gui/image/qxpmhandler.cpp b/src/gui/image/qxpmhandler.cpp
index ecfce93ee5..426a3ddf70 100644
--- a/src/gui/image/qxpmhandler.cpp
+++ b/src/gui/image/qxpmhandler.cpp
@@ -1137,8 +1137,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