]> granicus.if.org Git - clang/commitdiff
Teach ASTVector::append() about the case where 'NumInputs' is 0. This hopefully...
authorTed Kremenek <kremenek@apple.com>
Thu, 15 Apr 2010 01:14:12 +0000 (01:14 +0000)
committerTed Kremenek <kremenek@apple.com>
Thu, 15 Apr 2010 01:14:12 +0000 (01:14 +0000)
a crash in InitListExpr's ctor.

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

include/clang/AST/ASTVector.h

index a23ce87a91c9a01be0312fa0918efa68b8ffc20d..217dfade525f99fdadd703eb4895abb6a23807dd 100644 (file)
@@ -176,6 +176,10 @@ public:
   template<typename in_iter>
   void append(ASTContext &C, in_iter in_start, in_iter in_end) {
     size_type NumInputs = std::distance(in_start, in_end);
+
+    if (NumInputs == 0)
+      return;
+
     // Grow allocated space if needed.
     if (NumInputs > size_type(this->capacity_ptr()-this->end()))
       this->grow(C, this->size()+NumInputs);