]> granicus.if.org Git - clang/commitdiff
Fixed bug in child_begin/child_end for ReturnStmt where the iterator
authorTed Kremenek <kremenek@apple.com>
Mon, 27 Aug 2007 20:58:16 +0000 (20:58 +0000)
committerTed Kremenek <kremenek@apple.com>
Mon, 27 Aug 2007 20:58:16 +0000 (20:58 +0000)
would be invalid when RetValExp == NULL.

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

AST/Stmt.cpp

index 4aca7a49911d6e55d933993f07eeb6c982de1b35..c74e1a8ed016f134c78d869e0b0781882e20c750 100644 (file)
@@ -145,9 +145,13 @@ Stmt::child_iterator BreakStmt::child_begin() { return NULL; }
 Stmt::child_iterator BreakStmt::child_end() { return NULL; }
 
 // ReturnStmt
-Stmt::child_iterator ReturnStmt::child_begin() { 
-  return reinterpret_cast<Stmt**>(&RetExpr); 
+Stmt::child_iterator ReturnStmt::child_begin() {
+  if (RetExpr) return reinterpret_cast<Stmt**>(&RetExpr);
+  else return NULL;
 }
 
-Stmt::child_iterator ReturnStmt::child_end() { return child_begin()+1; }
+Stmt::child_iterator ReturnStmt::child_end() { 
+  if (RetExpr) return reinterpret_cast<Stmt**>(&RetExpr)+1;
+  else return NULL;
+}