Index: llvm/lib/Demangle/RustDemangle.cpp =================================================================== --- llvm/lib/Demangle/RustDemangle.cpp +++ llvm/lib/Demangle/RustDemangle.cpp @@ -164,7 +164,7 @@ } Demangler D; - if (!initializeOutputBuffer(nullptr, nullptr, D.Output, 1024)) { + if (!initializeOutputBuffer(Buf, N, D.Output, 1024)) { if (Status != nullptr) *Status = demangle_memory_alloc_failure; return nullptr; @@ -181,16 +181,6 @@ char *Demangled = D.Output.getBuffer(); size_t DemangledLen = D.Output.getCurrentPosition(); - if (Buf != nullptr) { - if (DemangledLen <= *N) { - std::memcpy(Buf, Demangled, DemangledLen); - std::free(Demangled); - Demangled = Buf; - } else { - std::free(Buf); - } - } - if (N != nullptr) *N = DemangledLen;