Commit 1fd0d57c authored by Marc Mutz's avatar Marc Mutz
Browse files

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: default avatarOswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Showing with 2 additions and 1 deletion
......@@ -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;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment