[COFF] Don't call memcpy with a NULL argument
authorDavid Majnemer <david.majnemer@gmail.com>
Sun, 20 Mar 2016 23:10:12 +0000 (23:10 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Sun, 20 Mar 2016 23:10:12 +0000 (23:10 +0000)
commit08af4e56e13e432afcdb46f07837abd4836e422d
tree6aa96ef8dd3e2a3c422846e3805ef4086470750b
parent2aa29ee7c150994d5be4acf9d13a678d97f07816
[COFF] Don't call memcpy with a NULL argument

Some declarations of memcpy (like glibc's for example) are attributed
with notnull which makes it UB for NULL to get passed in, even if the
memcpy count is zero.

To account for this, guard the memcpy with an appropriate precondition.

This should fix the last UBSan bug, exposed by the test suite, in the
COFF linker.

llvm-svn: 263919
lld/COFF/Writer.cpp