diff --git a/storage/tokudb/ha_tokudb.cc b/storage/tokudb/ha_tokudb.cc
index d0d5eeb842b4d73158a50fdc724140102d38a3d5..fc0266b65c17558d8ae4aceb388dd52ced928a4e 100644
--- a/storage/tokudb/ha_tokudb.cc
+++ b/storage/tokudb/ha_tokudb.cc
@@ -1234,7 +1234,7 @@ int ha_tokudb::open(const char *name, int mode, uint test_if_locked) {
           my_multi_malloc(MYF(MY_WME),
                           &key_buff, max_key_length, 
                           &key_buff2, max_key_length, 
-                          &primary_key_buff, (hidden_primary_key ? 0 : table_share->key_info[table_share->primary_key].key_length), 
+                          &primary_key_buff, (hidden_primary_key ? 0 : table_share->key_info[table_share->primary_key].key_length + sizeof(uchar)), 
                           NullS)))
         TOKUDB_DBUG_RETURN(1);
     if (!(rec_buff = (uchar *) my_malloc((alloced_rec_buff_length = table_share->rec_buff_length), MYF(MY_WME)))) {