summaryrefslogtreecommitdiffstats
path: root/src/corelib/io
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2014-11-28 20:13:55 -0800
committerThiago Macieira <thiago.macieira@intel.com>2015-01-02 14:58:10 +0100
commitcd407e1bc616bb98eef83d2b5c64513507ed1ef5 (patch)
tree93b7de895620ae7c2867b87a2b6d3a9bef7ffe26 /src/corelib/io
parent26b0ff7bad4c78edf4845fa4bf416bc17502da13 (diff)
Fix undefined behavior found by GCC 5
GCC said: qtldurl.cpp:51:50: error: loop exit may only be reached after undefined behavior [-Werror=aggressive-loop-optimizations] qtldurl.cpp:51:48: note: possible undefined statement is here while (tldIndices[index] >= tldChunks[chunk] && chunk < tldChunkCount) { ^ That's because we check whether chunk is still valid (less than tldChunkCount) after we've dereferenced tldChunks[chunk]. That is, we've already read tldChunk[2]. Change-Id: I79b6a1ea9a2454813d6cce7596fc2bb6d972d097 Reviewed-by: David Faure <david.faure@kdab.com>
Diffstat (limited to 'src/corelib/io')
-rw-r--r--src/corelib/io/qtldurl.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/corelib/io/qtldurl.cpp b/src/corelib/io/qtldurl.cpp
index d0205c3be5..7ccab8abb1 100644
--- a/src/corelib/io/qtldurl.cpp
+++ b/src/corelib/io/qtldurl.cpp
@@ -48,7 +48,7 @@ static bool containsTLDEntry(const QString &entry)
// select the right chunk from the big table
short chunk = 0;
uint chunkIndex = tldIndices[index], offset = 0;
- while (tldIndices[index] >= tldChunks[chunk] && chunk < tldChunkCount) {
+ while (chunk < tldChunkCount && tldIndices[index] >= tldChunks[chunk]) {
chunkIndex -= tldChunks[chunk];
offset += tldChunks[chunk];
chunk++;