aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Demangle/MicrosoftDemangle.cpp
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@acm.org>2022-03-24 04:21:52 -0700
committerNathan Sidwell <nathan@acm.org>2022-03-28 09:37:36 -0700
commitd1587c38e6baba70b81d02c31641a17e568a9f5c (patch)
tree7aa43334a08899c523fbdfef5b891eb1f56d3834 /llvm/lib/Demangle/MicrosoftDemangle.cpp
parent8a1956dfa590d5043dfb7be36013383bdcdc4fa7 (diff)
downloadllvm-d1587c38e6baba70b81d02c31641a17e568a9f5c.zip
llvm-d1587c38e6baba70b81d02c31641a17e568a9f5c.tar.gz
llvm-d1587c38e6baba70b81d02c31641a17e568a9f5c.tar.bz2
[llvm] Fix string copy confusion
The microsoft demangler makes copies of the demangled strings, but has some confusion between StringView representation (sans NUL), and C-strings (with NUL). Here we also have a use of strcpy, which happens to work because the incoming string view happens to have a trailing NUL. But a simple memcpy excluding the NUL is sufficient. Reviewed By: dblaikie, erichkeane Differential Revision: https://reviews.llvm.org/D122391
Diffstat (limited to 'llvm/lib/Demangle/MicrosoftDemangle.cpp')
-rw-r--r--llvm/lib/Demangle/MicrosoftDemangle.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/llvm/lib/Demangle/MicrosoftDemangle.cpp b/llvm/lib/Demangle/MicrosoftDemangle.cpp
index d8da3b48..a009bef 100644
--- a/llvm/lib/Demangle/MicrosoftDemangle.cpp
+++ b/llvm/lib/Demangle/MicrosoftDemangle.cpp
@@ -245,8 +245,8 @@ demanglePointerCVQualifiers(StringView &MangledName) {
}
StringView Demangler::copyString(StringView Borrowed) {
- char *Stable = Arena.allocUnalignedBuffer(Borrowed.size() + 1);
- std::strcpy(Stable, Borrowed.begin());
+ char *Stable = Arena.allocUnalignedBuffer(Borrowed.size());
+ std::memcpy(Stable, Borrowed.begin(), Borrowed.size());
return {Stable, Borrowed.size()};
}