Skip to content
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

[libclang] Always Dup in createRef(StringRef) #125020

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 1 addition & 13 deletions clang/tools/libclang/CXString.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,19 +87,7 @@ CXString createRef(StringRef String) {
if (String.empty())
return createEmpty();

// If the string is not nul-terminated, we have to make a copy.

// FIXME: This is doing a one past end read, and should be removed! For memory
// we don't manage, the API string can become unterminated at any time outside
// our control.

if (String.data()[String.size()] != 0)
return createDup(String);

CXString Result;
Result.data = String.data();
Result.private_flags = (unsigned) CXS_Unmanaged;
return Result;
return createDup(String);
}

CXString createDup(StringRef String) {
Expand Down