From 757640b15625eadd28a4cd6a24c23f66c13db0dc Mon Sep 17 00:00:00 2001 From: Howard Hinnant Date: Fri, 3 Aug 2012 22:02:07 +0000 Subject: [PATCH] Fixes apple: #12020687. This was a problem in the demangler with template substitution forward references. That is, sometimes a mangled name refers to a substitution that hasn't yet been defined. The demangler was derferencing a null pointer in this case because it wasn't properly guarded against a forward reference. Test case added to catch this problem. llvm-svn: 161267 --- libcxxabi/src/cxa_demangle.cpp | 5 +++-- libcxxabi/test/test_demangle.cpp | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/libcxxabi/src/cxa_demangle.cpp b/libcxxabi/src/cxa_demangle.cpp index d7f383eaed0f..b46a0581f581 100644 --- a/libcxxabi/src/cxa_demangle.cpp +++ b/libcxxabi/src/cxa_demangle.cpp @@ -17,7 +17,6 @@ #include #include - #ifdef DEBUGGING #include @@ -3701,6 +3700,8 @@ public: } virtual bool is_function() const { + if (__left_ == 0) + return false; return __left_->is_function(); } virtual bool is_cv_qualifer() const @@ -9196,7 +9197,7 @@ __demangle_tree::__parse_operator_name(const char* first, const char* last, int* case 'v': // cast { - const char* t = __parse_type(first+2, last, false); + const char* t = __parse_type(first+2, last, false, true); if (t != first+2) { __node* cast_type = __root_; diff --git a/libcxxabi/test/test_demangle.cpp b/libcxxabi/test/test_demangle.cpp index c8cc8530696a..45f265a9df58 100644 --- a/libcxxabi/test/test_demangle.cpp +++ b/libcxxabi/test/test_demangle.cpp @@ -29567,6 +29567,7 @@ const char* cases[][2] = {"_ZN2MF12_GLOBAL__N_114WeakCallHelperINS0_15DecodeQueueImplEEEvRKN5boost8functionIFvvEEERKNS3_8weak_ptrIT_EE", "void MF::(anonymous namespace)::WeakCallHelper(boost::function const&, boost::weak_ptr const&)"}, {"_ZZN4NIds4NStr14TCStrAggregateINS0_13TCTCStrTraitsINS0_11TCStrTraitsIcNS0_17CDefaultStrParamsEEENS0_14TCStrImp_FixedIS5_Lx256EEEEEE21f_AddFromIteratorUTF8INS0_16CStrIteratorUTF8EEEvRxRKT_ENKSA_ISB_EUlmE0_clEm", "void NIds::NStr::TCStrAggregate, NIds::NStr::TCStrImp_Fixed, 256ll> > >::f_AddFromIteratorUTF8(long long&, NIds::NStr::CStrIteratorUTF8 const&)::NIds::NStr::TCStrAggregate, NIds::NStr::TCStrImp_Fixed, 256ll> > >::f_AddFromIteratorUTF8::'lambda0'(unsigned long)::operator()(unsigned long) const"}, {"_ZZN4NIds4NStr14TCStrAggregateINS0_13TCTCStrTraitsINS0_11TCStrTraitsIcNS0_17CDefaultStrParamsEEENS0_14TCStrImp_FixedIS5_Lx256EEEEEE21f_AddFromIteratorUTF8INS0_16CStrIteratorUTF8EEEvRxRKT_ENKSA_ISB_EUt0_clEm", "void NIds::NStr::TCStrAggregate, NIds::NStr::TCStrImp_Fixed, 256ll> > >::f_AddFromIteratorUTF8(long long&, NIds::NStr::CStrIteratorUTF8 const&)::NIds::NStr::TCStrAggregate, NIds::NStr::TCStrImp_Fixed, 256ll> > >::f_AddFromIteratorUTF8::'unnamed0'::operator()(unsigned long) const"}, + {"_ZNK3com9markzware2js11cJSArgumentcvRKT_I8cMyClassEEv", "com::markzware::js::cJSArgument::operator cMyClass const &() const"}, }; const unsigned N = sizeof(cases) / sizeof(cases[0]);