qmake: fix UB in QMakeParser::putHashStr()
Found by UBSan: qmake/library/qmakeparser.cpp:278:33: runtime error: null pointer passed as argument 2, which is declared to never be null Guard the call. Change-Id: I99341ab439a511f366dae9344ddcc8727c33b9b6 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
This commit is contained in:
parent
f3487308e4
commit
1fd0d57ce3
@ -280,6 +280,7 @@ void QMakeParser::putHashStr(ushort *&pTokPtr, const ushort *buf, uint len)
|
|||||||
*tokPtr++ = (ushort)hash;
|
*tokPtr++ = (ushort)hash;
|
||||||
*tokPtr++ = (ushort)(hash >> 16);
|
*tokPtr++ = (ushort)(hash >> 16);
|
||||||
*tokPtr++ = (ushort)len;
|
*tokPtr++ = (ushort)len;
|
||||||
|
if (len) // buf may be nullptr; don't pass that to memcpy (-> undefined behavior)
|
||||||
memcpy(tokPtr, buf, len * 2);
|
memcpy(tokPtr, buf, len * 2);
|
||||||
pTokPtr = tokPtr + len;
|
pTokPtr = tokPtr + len;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user