From 0f9148ac9b6588dd18bd20d4a04de316cb84c766 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 25 Aug 2014 12:09:32 +0200 Subject: [PATCH] QRegion: fix a valgrind warning When: - i == 0 (at end of current POINTBLOCK), - numFullPtBlocks == 1 (only one more POINTBLOCK left) and - iCurPtBlock == 0 (last block contains no points), Valgrind rightfully complained about an invalid read: Conditional jump or move depends on uninitialised value(s) at 0x517B08B: PolygonRegion(QPoint const*, int, int) (qregion.cpp:3480) Fixed by setting 'next' to nullptr when !numFullPtBlocks OR !iCurPtBlock. Change-Id: If5225fdfa66f2910a8aafb675cd02b40c0a81ad9 Reviewed-by: Olivier Goffart --- src/gui/painting/qregion.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/painting/qregion.cpp b/src/gui/painting/qregion.cpp index 6bf5f6bf88..c556edd4c0 100644 --- a/src/gui/painting/qregion.cpp +++ b/src/gui/painting/qregion.cpp @@ -3472,7 +3472,7 @@ static void PtsToRegion(int numFullPtBlocks, int iCurPtBlock, } if (rowSize) { - QPoint *next = i ? &pts[2] : (numFullPtBlocks ? CurPtBlock->next->pts : 0); + QPoint *next = i ? &pts[2] : (numFullPtBlocks && iCurPtBlock ? CurPtBlock->next->pts : Q_NULLPTR); if (!next || next->y() != pts[0].y()) { flushRow(row.data(), pts[0].y(), rowSize, reg, &lastRow, &extendTo, &needsExtend);