diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2015-08-04 03:52:58 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2015-08-04 03:52:58 +0000 |
commit | f0c627d5f8a4d006d711e1d1e0c2028fdf346d8c (patch) | |
tree | 48e47bc29ee55d7a4feb92e0fad98722445445ea /clang/lib/AST/Stmt.cpp | |
parent | b6708d8ebf05cb3e09ea0ab495d2d45e0ca997a4 (diff) | |
download | bcm5719-llvm-f0c627d5f8a4d006d711e1d1e0c2028fdf346d8c.tar.gz bcm5719-llvm-f0c627d5f8a4d006d711e1d1e0c2028fdf346d8c.zip |
[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
Diffstat (limited to 'clang/lib/AST/Stmt.cpp')
-rw-r--r-- | clang/lib/AST/Stmt.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/clang/lib/AST/Stmt.cpp b/clang/lib/AST/Stmt.cpp index 7aab1371a28..181a3b4666b 100644 --- a/clang/lib/AST/Stmt.cpp +++ b/clang/lib/AST/Stmt.cpp @@ -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); |