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,7 +280,8 @@ void QMakeParser::putHashStr(ushort *&pTokPtr, const ushort *buf, uint len)
|
||||
*tokPtr++ = (ushort)hash;
|
||||
*tokPtr++ = (ushort)(hash >> 16);
|
||||
*tokPtr++ = (ushort)len;
|
||||
memcpy(tokPtr, buf, len * 2);
|
||||
if (len) // buf may be nullptr; don't pass that to memcpy (-> undefined behavior)
|
||||
memcpy(tokPtr, buf, len * 2);
|
||||
pTokPtr = tokPtr + len;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user