Commit bbb353b1 authored by Marc Mutz's avatar Marc Mutz Committed by Oswald Buddenhagen

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>
(cherry picked from qtbase/1fd0d57ce3da83631423d17faadf97133f5c7835)
Reviewed-by: default avatarMarc Mutz <marc.mutz@kdab.com>
Reviewed-by: Jake Petroules's avatarJake Petroules <jake.petroules@qt.io>
parent 73fead33
......@@ -272,7 +272,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;
}
......
Markdown is supported
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