44 lines
1.9 KiB
Diff
44 lines
1.9 KiB
Diff
From 76113c63af23d516f488f5e6b9062ca97e062e9e Mon Sep 17 00:00:00 2001
|
|
From: Marc Mutz <marc.mutz@kdab.com>
|
|
Date: Tue, 16 Jul 2019 11:23:37 +0200
|
|
Subject: [PATCH 13/18] QSGOpenGLDistanceFieldGlyphCache: fix multiplication
|
|
result truncation
|
|
|
|
The type of the expression int * int is int, so truncation has already
|
|
happened when the result is assigned to a qint64.
|
|
|
|
Fix by casting one of the multiplicants to qint64 before performing
|
|
the multiplication. This multiplication cannot overflow, because int
|
|
is 32-bit on all supported platforms.
|
|
|
|
The addition of 'size' to the pointer will still truncate the result,
|
|
on 32bit platforms, but that check is in itself UB. A follow-up commit
|
|
will fix the check, and with it the last truncation to 32bit.
|
|
|
|
Coverity-Id: 218769
|
|
Pick-to: 6.3 6.2 5.15
|
|
Change-Id: I0d71950695b9743db8c96d825e68bb1e9c47de02
|
|
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
|
|
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
|
|
(cherry picked from commit cacfc1dbb9719c0ef55cff69dad0921ce1405438)
|
|
---
|
|
src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp | 2 +-
|
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
|
|
diff --git a/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp b/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
|
|
index 53b6fe117f..f7cb8bede3 100644
|
|
--- a/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
|
|
+++ b/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
|
|
@@ -512,7 +512,7 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
|
|
|
|
int width = texInfo->allocatedArea.width();
|
|
int height = texInfo->allocatedArea.height();
|
|
- qint64 size = width * height;
|
|
+ qint64 size = qint64(width) * height;
|
|
if (reinterpret_cast<const char *>(textureData + size) > qtdfTableEnd) {
|
|
qWarning("qtdf table too small in font '%s'.",
|
|
qPrintable(font.familyName()));
|
|
--
|
|
2.37.3
|
|
|