This protects lld from a null pointer dereference when a faulty input file has such invalid sh_link fields.
Details
Details
Diff Detail
Diff Detail
- Repository
- rLLD LLVM Linker
Event Timeline
ELF/InputFiles.cpp | ||
---|---|---|
481–484 | It feels like setting to a nullptr is a little bit tricky. I'd probably keep the original code for this line, and add another null check after InputSectionBase *LinkSec = this->Sections[Sec.sh_link]; |
ELF/InputFiles.cpp | ||
---|---|---|
481–484 | Duplicate fatal calls seem verbose if (Sec.sh_link >= this->Sections.size()) fatal(toString(this) + ": invalid sh_link index: " + Twine(Sec.sh_link)); InputSectionBase *LinkSec = this->Sections[Sec.sh_link]; if (!LinkSec) fatal(toString(this) + ": invalid sh_link index: " + Twine(Sec.sh_link)); How about the current change? |
It feels like setting to a nullptr is a little bit tricky. I'd probably keep the original code for this line, and add another null check after InputSectionBase *LinkSec = this->Sections[Sec.sh_link];