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 <ogoffart@woboq.com>
This commit is contained in:
Marc Mutz 2014-08-25 12:09:32 +02:00
parent 9af1d11fcf
commit 0f9148ac9b

View File

@ -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);