[PATCH] D45789: Fix nullptr passed to memcpy in lld/COFF/Chunks.cpp
Rui Ueyama via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 18 16:57:17 PDT 2018
ruiu added inline comments.
================
Comment at: lld/COFF/Chunks.cpp:274-276
+ if (!A.data())
+ return;
memcpy(Buf + OutputSectionOff, A.data(), A.size());
----------------
I feel like
if (A.size() > 0)
memcpy(...)
is slightly better. Returning from the function is correct because we only process relocations after this point in this function, and if a section is size 0, there should be no relocations. But I had to think for a while to understand that doing it is correct. So, just skipping memcpy would be slightly better in my opinion.
https://reviews.llvm.org/D45789
More information about the llvm-commits
mailing list