-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle null from LLVMRustGetSectionName #62460
Conversation
r? @eddyb (rust_highfive has picked a reviewer for you, use r? to override) |
let name_len = llvm::LLVMRustGetSectionName(si.llsi, &mut name_buf); | ||
let name = slice::from_raw_parts(name_buf as *const u8, name_len as usize).to_vec(); | ||
let name = String::from_utf8(name).unwrap(); | ||
let name = name_buf.map_or( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the purposes of this code, sections without name can be skipped entirely. I'm also wondering why this code is creating a String
rather than a str
, it does not seem necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you saying I should change something? I literally have no idea what the code here is doing, I'm afraid. @nitnelave just did the minimal thing to avoid NULL references.
@bors r+ |
📌 Commit 076a5cd has been approved by |
☀️ Test successful - checks-azure, checks-travis, status-appveyor |
Tested on commit rust-lang/rust@8895384. Direct link to PR: <rust-lang/rust#62460> 💔 rls on linux: test-pass → test-fail (cc @Xanewok, @rust-lang/infra).
As part of #58783 and #62103, this incorrect use of a NULL pointer was found in the interface to LLVM. That PR is stuck with some linker issues, but there is no reason the soundness fix should have to wait for that.