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) {