This is an archive of the discontinued LLVM Phabricator instance.

[LLD][ELF] Fix nullptr dereference when creating an error message.
ClosedPublic

Authored by seaneveson on Jun 28 2017, 7:50 AM.

Diff Detail

Repository
rL LLVM

Event Timeline

seaneveson created this revision.Jun 28 2017, 7:50 AM
ruiu edited edge metadata.Jun 28 2017, 8:01 AM

Thank you for your patch!

Could you add a test?

ELF/InputSection.cpp
279 ↗(On Diff #104417)

You want to return "(internal):" + Name + "+0x" + utohexstr(Off) +")" here if File is null, so that you can remove the null checks below.

Changed to early return as requested.

I haven't been able to find a way to test this, as the crash only occurs for errors in internal sections and I can't find a good way to force one. Do you have any ideas?

Thanks for the review.

ruiu added a comment.Jun 29 2017, 11:10 AM

Can you test this if you pass a broken object file to the linker?

seaneveson updated this revision to Diff 105052.Jul 3 2017, 4:53 AM
  • Added a test
  • Fixed a missing brace in the error message string
This revision was automatically updated to reflect the committed changes.