ubsan found that we sometimes pass nullptr to memcpy in
SectionChunk::writeTo(). This change adds a check that avoids that.
Details
Details
Diff Detail
Diff Detail
- Build Status
Buildable 17298 Build 17298: arc lint + arc unit
Event Timeline
lld/COFF/Chunks.cpp | ||
---|---|---|
274–276 | 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. |
Comment Actions
This is not actually that important, but I think I prefer my original suggestion. At least we shouldn't use assert() to report a broken file.
Comment Actions
Fair enough. Changed it to only do the memcpy if the ArrayRef is not
empty, and otherwise leave the function alone.
I feel like
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.