diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc
index eec66a5553e1fd598b68c4e60518846ff544cb39..0fc5884447c2f133e3e285c9c7a7cdb15c4234d0 100644
--- a/sql/sql_partition.cc
+++ b/sql/sql_partition.cc
@@ -1269,6 +1269,11 @@ static void check_fields_in_PF(Field **ptr, bool *all_fields,
 
   *all_fields= TRUE;
   *some_fields= FALSE;
+  if ((!ptr) || !(*ptr))
+  {
+    *all_fields= FALSE;
+    DBUG_VOID_RETURN;
+  }
   do
   {
   /* Check if the field of the PF is part of the current key investigated */