From 7fd563d28342862dcb83e253f89844cc2dfd4e54 Mon Sep 17 00:00:00 2001 From: Eric Christopher Date: Fri, 30 Jun 2017 05:38:56 +0000 Subject: [PATCH] Rewrite demangle memory handling. The return of itaniumDemangle is allocated with malloc rather than new[] and so using unique_ptr isn't called for here. As a note for the future we should rewrite it to do this. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@306788 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/llvm-nm/llvm-nm.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/llvm-nm/llvm-nm.cpp b/tools/llvm-nm/llvm-nm.cpp index b25c4775e8d..ea47891250f 100644 --- a/tools/llvm-nm/llvm-nm.cpp +++ b/tools/llvm-nm/llvm-nm.cpp @@ -672,12 +672,14 @@ static Optional demangle(StringRef Name, bool StripUnderscore) { return None; int Status; - std::unique_ptr Undecorated( - itaniumDemangle(Name.str().c_str(), nullptr, nullptr, &Status)); + char *Undecorated = + itaniumDemangle(Name.str().c_str(), nullptr, nullptr, &Status); if (Status != 0) return None; - return std::string(Undecorated.get()); + std::string S(Undecorated); + free(Undecorated); + return S; } static bool symbolIsDefined(const NMSymbol &Sym) { -- 2.50.0