diff options
author | Nico Weber <nicolasweber@gmx.de> | 2019-04-15 16:42:44 +0000 |
---|---|---|
committer | Nico Weber <nicolasweber@gmx.de> | 2019-04-15 16:42:44 +0000 |
commit | 64041d7b90714aa6f0542c64ec5bb327beecfc58 (patch) | |
tree | a86d12636f18d66d66e5860792617c58add0aa59 /llvm/lib | |
parent | 0e0bb0e24a0c1257c675300d4fc42576f5ca5566 (diff) | |
download | bcm5719-llvm-64041d7b90714aa6f0542c64ec5bb327beecfc58.tar.gz bcm5719-llvm-64041d7b90714aa6f0542c64ec5bb327beecfc58.zip |
llvm-undname: Fix nullptr deref on invalid conversion operator names in template args
A ConversionOperatorIdentifierNode has a TargetType which is read when
printing it, but if the ConversionOperatorIdentifierNode appears in a
template argument there's nothing that can provide the TargetType.
Normally the COIN is a symbol (leaf) name and takes its TargetType from the
symbol's type, but in a template argument context the COIN can only be
either a non-leaf name piece or a type, and must hence be invalid.
Similar to the COIN check in demangleDeclarator().
Found by oss-fuzz.
llvm-svn: 358421
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Demangle/MicrosoftDemangle.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/llvm/lib/Demangle/MicrosoftDemangle.cpp b/llvm/lib/Demangle/MicrosoftDemangle.cpp index 2b41c0037f9..c3bdfa23d1f 100644 --- a/llvm/lib/Demangle/MicrosoftDemangle.cpp +++ b/llvm/lib/Demangle/MicrosoftDemangle.cpp @@ -947,8 +947,17 @@ Demangler::demangleTemplateInstantiationName(StringView &MangledName, if (Error) return nullptr; - if (NBB & NBB_Template) + if (NBB & NBB_Template) { + // NBB_Template is only set for types and non-leaf names ("a::" in "a::b"). + // A conversion operator only makes sense in a leaf name , so reject it in + // NBB_Template contexts. + if (Identifier->kind() == NodeKind::ConversionOperatorIdentifier) { + Error = true; + return nullptr; + } + memorizeIdentifier(Identifier); + } return Identifier; } |