diff --git a/sql/protocol.cc b/sql/protocol.cc
index 6699196fbc7f8464321c75a58151c5232feef648..16975c68a54c4cce4eedbf775cc08dd83ec27dd5 100644
--- a/sql/protocol.cc
+++ b/sql/protocol.cc
@@ -598,7 +598,8 @@ bool Protocol::send_fields(List<Item> *list, uint flags)
                      field.length / item->collation.collation->mbminlen :
                      field.length / item->collation.collation->mbmaxlen;
         max_length*= thd_charset->mbmaxlen;
-        field_length= (max_length > UINT_MAX32) ? UINT_MAX32 : max_length;
+        field_length= (max_length > UINT_MAX32) ? 
+          UINT_MAX32 : (uint32) max_length;
         int4store(pos + 2, field_length);
       }
       pos[6]= field.type;