mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-27 12:56:08 +00:00
[UB] When attaching empty strings to the AST, use an empty StringRef
rather than forcing the bump pointer allocator to produce a viable pointer. This also fixes UB when we would try to memcpy from the null incoming StringRef. llvm-svn: 243947
This commit is contained in:
parent
b6708d8ebf
commit
f0c627d5f8
@ -724,6 +724,8 @@ MSAsmStmt::MSAsmStmt(const ASTContext &C, SourceLocation asmloc,
|
||||
}
|
||||
|
||||
static StringRef copyIntoContext(const ASTContext &C, StringRef str) {
|
||||
if (str.empty())
|
||||
return StringRef();
|
||||
size_t size = str.size();
|
||||
char *buffer = new (C) char[size];
|
||||
memcpy(buffer, str.data(), size);
|
||||
|
Loading…
x
Reference in New Issue
Block a user