From: Nico Weber Date: Thu, 18 Apr 2019 19:30:21 +0000 (+0000) Subject: llvm-undname: Fix two asserts-on-invalid X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=502cf4bd19f9aaf4c412de147912cd178fe40e20;p=platform%2Fupstream%2Fllvm.git llvm-undname: Fix two asserts-on-invalid llvm-svn: 358707 --- diff --git a/llvm/lib/Demangle/MicrosoftDemangle.cpp b/llvm/lib/Demangle/MicrosoftDemangle.cpp index cd71e72..1322738 100644 --- a/llvm/lib/Demangle/MicrosoftDemangle.cpp +++ b/llvm/lib/Demangle/MicrosoftDemangle.cpp @@ -838,7 +838,7 @@ VariableSymbolNode *Demangler::demangleVariableEncoding(StringView &MangledName, // ::= [?] // // ::= # when 1 <= Number <= 10 -// ::= + @ # when Numbrer == 0 or >= 10 +// ::= + @ # when Number == 0 or >= 10 // // ::= [A-P] # A = 0, B = 1, ... std::pair Demangler::demangleNumber(StringView &MangledName) { @@ -1269,7 +1269,8 @@ Demangler::demangleStringLiteral(StringView &MangledName) { Result->IsTruncated = true; while (!MangledName.consumeFront('@')) { - assert(StringByteSize >= 2); + if (StringByteSize < 2) + goto StringLiteralError; wchar_t W = demangleWcharLiteral(MangledName); if (StringByteSize != 2 || Result->IsTruncated) outputEscapedChar(OS, W); @@ -1285,7 +1286,8 @@ Demangler::demangleStringLiteral(StringView &MangledName) { unsigned BytesDecoded = 0; while (!MangledName.consumeFront('@')) { - assert(StringByteSize >= 1); + if (StringByteSize < 1) + goto StringLiteralError; StringBytes[BytesDecoded++] = demangleCharLiteral(MangledName); } diff --git a/llvm/test/Demangle/invalid-manglings.test b/llvm/test/Demangle/invalid-manglings.test index 84c2b32..c4a75e3 100644 --- a/llvm/test/Demangle/invalid-manglings.test +++ b/llvm/test/Demangle/invalid-manglings.test @@ -139,3 +139,13 @@ ; CHECK-EMPTY: ; CHECK-NEXT: ?foo@?$?0H@ ; CHECK-NEXT: error: Invalid mangled name + +??_C@_0A@01234567@a +; CHECK-EMPTY: +; CHECK-NEXT: ??_C@_0A@01234567@a +; CHECK-NEXT: error: Invalid mangled name + +??_C@_1A@01234567@a +; CHECK-EMPTY: +; CHECK-NEXT: ??_C@_1A@01234567@a +; CHECK-NEXT: error: Invalid mangled name