From cd407e1bc616bb98eef83d2b5c64513507ed1ef5 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 28 Nov 2014 20:13:55 -0800 Subject: 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 --- src/corelib/io/qtldurl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib/io') 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++; -- cgit v1.2.3