]> granicus.if.org Git - clang/commitdiff
Avoid accessing invalid std::vector element; this makes clang
authorDaniel Dunbar <daniel@zuster.org>
Sat, 1 Aug 2009 23:40:20 +0000 (23:40 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Sat, 1 Aug 2009 23:40:20 +0000 (23:40 +0000)
ENABLE_EXPENSIVE_CHECKS clean on x86_64-.*-darwin10.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77831 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/DeclCXX.cpp

index cc481be6ba89a83f2eec1c1dde56a32f52112d13..4a2f799b273ae8f4feff6462a8543e5169b370f8 100644 (file)
@@ -348,8 +348,9 @@ CXXMethodDecl::method_iterator CXXMethodDecl::begin_overridden_methods() const {
     return 0;
   
   OverriddenMethodsMapTy::iterator it = OverriddenMethods->find(this);
-  if (it == OverriddenMethods->end())
+  if (it == OverriddenMethods->end() || it->second->empty())
     return 0;
+
   return &(*it->second)[0];
 }
 
@@ -358,7 +359,7 @@ CXXMethodDecl::method_iterator CXXMethodDecl::end_overridden_methods() const {
     return 0;
   
   OverriddenMethodsMapTy::iterator it = OverriddenMethods->find(this);
-  if (it == OverriddenMethods->end())
+  if (it == OverriddenMethods->end() || it->second->empty())
     return 0;
 
   return &(*it->second)[it->second->size()];