[llvm] [pdb] Store symbol names without null terminators in PublicsStreamTest (PR #190790)
Alexandre Ganea via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 7 06:50:53 PDT 2026
================
@@ -24,6 +26,15 @@ using namespace llvm::pdb;
namespace {
struct PublicSym {
+ PublicSym(StringRef N, uint16_t Seg, uint32_t Off)
+ : NameData(new char[N.size()]), Name(NameData.get(), N.size()),
+ Segment(Seg), Offset(Off) {
+ // Store the name without null terminator on the heap to help catch issues
+ // with code assuming there is a null terminator.
+ memcpy(NameData.get(), N.data(), N.size());
+ }
+
+ std::unique_ptr<char[]> NameData;
----------------
aganea wrote:
I think a comment here on this member, or the comment above can be expanded to explain really why we're doing this, ie. to catch out-of-bounds accesses with ASan in case Name.data() is used as a null-terminated buffer.
https://github.com/llvm/llvm-project/pull/190790
More information about the llvm-commits
mailing list