summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2015-01-18 21:57:20 +0100
committerMarc Mutz <marc.mutz@kdab.com>2015-01-19 10:41:57 +0100
commit62a96dbb53d77d6cd7320c6fc8d33ee9c4add0fe (patch)
tree2011eff65f63b4582a0728d3315ff67cd0abcb3c
parent390ea21873cf229447c2dcaea85a40e472fab03c (diff)
QTextFormat: fix undefined behavior
Left-shifting of negative values is undefined ([expr.shift]/2). Since hashValue is a uint already, rectify by casting it->key to uint prior to shifting. Found by UBSan. Change-Id: I94a5311f5a4492f514f595b8fb79726df1e7d0de Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
-rw-r--r--src/gui/text/qtextformat.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/gui/text/qtextformat.cpp b/src/gui/text/qtextformat.cpp
index cecfd85df1..ecd87188e7 100644
--- a/src/gui/text/qtextformat.cpp
+++ b/src/gui/text/qtextformat.cpp
@@ -319,7 +319,7 @@ uint QTextFormatPrivate::recalcHash() const
{
hashValue = 0;
for (QVector<Property>::ConstIterator it = props.constBegin(); it != props.constEnd(); ++it)
- hashValue += (it->key << 16) + variantHash(it->value);
+ hashValue += (static_cast<quint32>(it->key) << 16) + variantHash(it->value);
hashDirty = false;