diff --git a/src/search.c b/src/search.c
index 1c9272e..26f4df4 100644
--- a/src/search.c
+++ b/src/search.c
@@ -378,6 +378,7 @@ EXECUTE_FCT(EGexecute)
   struct kwsmatch kwsm;
   size_t i, ret_val;
 #ifdef MBS_SUPPORT
+  size_t case_size = size;
   char *mb_properties = NULL;
   if (MB_CUR_MAX > 1)
     {
@@ -385,14 +386,14 @@ EXECUTE_FCT(EGexecute)
         {
           /* mbtolower adds a NUL byte at the end.  That will provide
              space for the sentinel byte dfaexec may add.  */
-          char *case_buf = mbtolower (buf, &size);
+          char *case_buf = mbtolower (buf, &case_size);
           if (start_ptr)
             start_ptr = case_buf + (start_ptr - buf);
           buf = case_buf;
         }
 
       if (kwset)
-        mb_properties = check_multibyte_string(buf, size);
+        mb_properties = check_multibyte_string(buf, case_size);
     }
 #endif /* MBS_SUPPORT */
