diff --git a/storage/myisam/sort.c b/storage/myisam/sort.c
index 099c3173396d8007d34e6b27d8fad2367e08ba2f..9d7eda9f5baa1753cea17b7ed91c11824cc15635 100644
--- a/storage/myisam/sort.c
+++ b/storage/myisam/sort.c
@@ -324,7 +324,7 @@ pthread_handler_t thr_find_all_keys(void *arg)
   if (info->sort_info->got_error)
     goto err;
 
-  if (info->keyinfo->flag && HA_VAR_LENGTH_KEY)
+  if (info->keyinfo->flag & HA_VAR_LENGTH_KEY)
   {
     info->write_keys=write_keys_varlen;
     info->read_to_buffer=read_to_buffer_varlen;
@@ -517,7 +517,7 @@ int thr_write_keys(MI_SORT_PARAM *sort_param)
   {
     if (got_error)
       continue;
-    if (sinfo->keyinfo->flag && HA_VAR_LENGTH_KEY)
+    if (sinfo->keyinfo->flag & HA_VAR_LENGTH_KEY)
     {
       sinfo->write_keys=write_keys_varlen;
       sinfo->read_to_buffer=read_to_buffer_varlen;