diff options
Diffstat (limited to 'llvm/lib/Demangle/MicrosoftDemangle.cpp')
-rw-r--r-- | llvm/lib/Demangle/MicrosoftDemangle.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/llvm/lib/Demangle/MicrosoftDemangle.cpp b/llvm/lib/Demangle/MicrosoftDemangle.cpp index 26087a5..aca8cf7 100644 --- a/llvm/lib/Demangle/MicrosoftDemangle.cpp +++ b/llvm/lib/Demangle/MicrosoftDemangle.cpp @@ -966,6 +966,9 @@ void Demangler::memorizeIdentifier(IdentifierNode *Identifier) { // Render this class template name into a string buffer so that we can // memorize it for the purpose of back-referencing. OutputBuffer OB; + if (!initializeOutputBuffer(nullptr, nullptr, OB, 1024)) + // FIXME: Propagate out-of-memory as an error? + std::terminate(); Identifier->output(OB, OF_Default); StringView Owned = copyString(OB); memorizeString(Owned); @@ -1276,6 +1279,11 @@ Demangler::demangleStringLiteral(StringView &MangledName) { EncodedStringLiteralNode *Result = Arena.alloc<EncodedStringLiteralNode>(); + // Must happen before the first `goto StringLiteralError`. + if (!initializeOutputBuffer(nullptr, nullptr, OB, 1024)) + // FIXME: Propagate out-of-memory as an error? + std::terminate(); + // Prefix indicating the beginning of a string literal if (!MangledName.consumeFront("@_")) goto StringLiteralError; @@ -1434,6 +1442,9 @@ Demangler::demangleLocallyScopedNamePiece(StringView &MangledName) { // Render the parent symbol's name into a buffer. OutputBuffer OB; + if (!initializeOutputBuffer(nullptr, nullptr, OB, 1024)) + // FIXME: Propagate out-of-memory as an error? + std::terminate(); OB << '`'; Scope->output(OB, OF_Default); OB << '\''; @@ -2296,6 +2307,8 @@ void Demangler::dumpBackReferences() { // Create an output stream so we can render each type. OutputBuffer OB; + if (!initializeOutputBuffer(nullptr, nullptr, OB, 1024)) + std::terminate(); for (size_t I = 0; I < Backrefs.FunctionParamCount; ++I) { OB.setCurrentPosition(0); @@ -2322,6 +2335,7 @@ char *llvm::microsoftDemangle(const char *MangledName, size_t *NMangled, char *Buf, size_t *N, int *Status, MSDemangleFlags Flags) { Demangler D; + OutputBuffer OB; StringView Name{MangledName}; SymbolNode *AST = D.parse(Name); @@ -2346,8 +2360,9 @@ char *llvm::microsoftDemangle(const char *MangledName, size_t *NMangled, int InternalStatus = demangle_success; if (D.Error) InternalStatus = demangle_invalid_mangled_name; + else if (!initializeOutputBuffer(Buf, N, OB, 1024)) + InternalStatus = demangle_memory_alloc_failure; else { - OutputBuffer OB(Buf, N); AST->output(OB, OF); OB += '\0'; if (N != nullptr) |