From 5b3ed283f578a63777cd7f3b9924aea79c2b8b7a Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Mon, 27 Aug 2007 20:58:16 +0000 Subject: [PATCH] Fixed bug in child_begin/child_end for ReturnStmt where the iterator would be invalid when RetValExp == NULL. llvm-svn: 41511 --- clang/AST/Stmt.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/clang/AST/Stmt.cpp b/clang/AST/Stmt.cpp index 4aca7a49911d..c74e1a8ed016 100644 --- a/clang/AST/Stmt.cpp +++ b/clang/AST/Stmt.cpp @@ -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(&RetExpr); +Stmt::child_iterator ReturnStmt::child_begin() { + if (RetExpr) return reinterpret_cast(&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(&RetExpr)+1; + else return NULL; +}