diff --git a/src/plugins/cppeditor/cppquickfix.cpp b/src/plugins/cppeditor/cppquickfix.cpp
index 4cb5f9443553ccb0051fb6fcd176096046d2640e..5fa31660ebf508e723f329de7befdea164803011 100644
--- a/src/plugins/cppeditor/cppquickfix.cpp
+++ b/src/plugins/cppeditor/cppquickfix.cpp
@@ -443,7 +443,7 @@ public:
         // show when we're on the 'if' of an if statement
         int index = path.size() - 1;
         IfStatementAST *ifStatement = path.at(index)->asIfStatement();
-        if (ifStatement && isCursorOn(ifStatement->if_token)
+        if (ifStatement && isCursorOn(ifStatement->if_token) && ifStatement->statement
             && ! ifStatement->statement->asCompoundStatement()) {
             _statement = ifStatement->statement;
             return index;