diff --git a/sql/table.cc b/sql/table.cc
index 620a0d6231675ef02606aedc7756ecf5524bc813..a78d245ba9dbb2d919fd07f2eb6ecc71a01f760e 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -661,7 +661,7 @@ int openfrm(THD *thd, const char *name, const char *alias, uint db_stat,
 	    if (!(field->flags & BINARY_FLAG))
 	      keyinfo->flags|= HA_END_SPACE_KEY;
 	  }
-          set_if_bigger(outparam->max_key_length, keyinfo->key_length);
+          set_if_bigger(share->max_key_length, keyinfo->key_length);
 	  if (field->type() == MYSQL_TYPE_BIT)
             key_part->key_part_flag|= HA_BIT_PART;