diff --git a/src/plugins/cppeditor/cppquickfix.cpp b/src/plugins/cppeditor/cppquickfix.cpp
index b09468d23e749acd4abf42bb7e9168462c909030..4974e25591f04d950ed279df2e47b38efff1ab3e 100644
--- a/src/plugins/cppeditor/cppquickfix.cpp
+++ b/src/plugins/cppeditor/cppquickfix.cpp
@@ -275,6 +275,9 @@ public:
 
     virtual int match(const QList<AST *> &path)
     {
+        if (path.size() == 0)
+            return -1;        
+
         // show when we're on the 'if' of an if statement
         int index = path.size() - 1;
         IfStatementAST *ifStatement = path.at(index)->asIfStatement();