diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 94b37e164e70f3571085efa05cd20fe55071dcea..745d9ea1084bbd9708a43a9377735989300e55f7 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -1049,6 +1049,11 @@ static int prepare_for_repair(THD* thd, TABLE_LIST* table,
 {
   DBUG_ENTER("prepare_for_repair");
 
+  if (!table->table)
+  {
+    DBUG_RETURN(send_check_errmsg(thd, table, "repair", "table is read-only or does not exists"));
+  }
+
   if (!(check_opt->sql_flags & TT_USEFRM))
   {
     DBUG_RETURN(0);