diff --git a/MagickCore/cache.c b/MagickCore/cache.c
index 805a018..29dd17d 100644
--- a/MagickCore/cache.c
+++ b/MagickCore/cache.c
@@ -3232,7 +3232,7 @@
         format[MaxTextExtent],
         message[MaxTextExtent];
 
-      (void) FormatMagickSize(length,MagickFalse,"B",format);
+      (void) FormatMagickSize(length,MagickFalse,"B",MaxTextExtent,format);
       (void) FormatLocaleString(message,MaxTextExtent,
         "extend %s (%s[%d], disk, %s)",cache_info->filename,
         cache_info->cache_filename,cache_info->file,format);
@@ -3364,7 +3364,7 @@
               if (image->debug != MagickFalse)
                 {
                   (void) FormatMagickSize(cache_info->length,MagickTrue,"B",
-                    format);
+                    MaxTextExtent,format);
                   type=CommandOptionToMnemonic(MagickCacheOptions,(ssize_t)
                     cache_info->type);
                   (void) FormatLocaleString(message,MaxTextExtent,
@@ -3424,7 +3424,7 @@
               if (image->debug != MagickFalse)
                 {
                   (void) FormatMagickSize(cache_info->length,MagickFalse,"B",
-                    format);
+                    MaxTextExtent,format);
                   type=CommandOptionToMnemonic(MagickCacheOptions,(ssize_t)
                     cache_info->type);
                   (void) FormatLocaleString(message,MaxTextExtent,
@@ -3507,7 +3507,7 @@
               if (image->debug != MagickFalse)
                 {
                   (void) FormatMagickSize(cache_info->length,MagickTrue,"B",
-                    format);
+                    MaxTextExtent,format);
                   type=CommandOptionToMnemonic(MagickCacheOptions,(ssize_t)
                     cache_info->type);
                   (void) FormatLocaleString(message,MaxTextExtent,
@@ -3532,7 +3532,8 @@
     }
   if (image->debug != MagickFalse)
     {
-      (void) FormatMagickSize(cache_info->length,MagickFalse,"B",format);
+      (void) FormatMagickSize(cache_info->length,MagickFalse,"B",MaxTextExtent,
+        format);
       type=CommandOptionToMnemonic(MagickCacheOptions,(ssize_t)
         cache_info->type);
       (void) FormatLocaleString(message,MaxTextExtent,
diff --git a/MagickCore/identify.c b/MagickCore/identify.c
index 8b11420..4cb815c 100644
--- a/MagickCore/identify.c
+++ b/MagickCore/identify.c
@@ -600,7 +600,7 @@
           if (image->total_colors != 0)
             {
               (void) FormatMagickSize(image->total_colors,MagickFalse,"B",
-                format);
+                MaxTextExtent,format);
               (void) FormatLocaleFile(file,"%s ",format);
             }
         }
@@ -619,7 +619,7 @@
       if (GetBlobSize(image) != 0)
         {
           (void) FormatMagickSize(GetBlobSize(image),MagickFalse,"B",
-            format);
+            MaxTextExtent,format);
           (void) FormatLocaleFile(file,"%s ",format);
         }
       (void) FormatLocaleFile(file,"%0.3fu %lu:%02lu.%03lu",user_time,
@@ -1383,15 +1383,16 @@
     }
   (void) FormatLocaleFile(file,"  Tainted: %s\n",CommandOptionToMnemonic(
     MagickBooleanOptions,(ssize_t) image->taint));
-  (void) FormatMagickSize(GetBlobSize(image),MagickFalse,"B",format);
+  (void) FormatMagickSize(GetBlobSize(image),MagickFalse,"B",MaxTextExtent,
+    format);
   (void) FormatLocaleFile(file,"  Filesize: %s\n",format);
   (void) FormatMagickSize((MagickSizeType) image->columns*image->rows,
-    MagickFalse,"B",format);
+    MagickFalse,"B",MaxTextExtent,format);
   if (strlen(format) > 1)
     format[strlen(format)-1]='\0';
   (void) FormatLocaleFile(file,"  Number pixels: %s\n",format);
   (void) FormatMagickSize((MagickSizeType) ((double) image->columns*image->rows/
-    elapsed_time+0.5),MagickFalse,"B",format);
+    elapsed_time+0.5),MagickFalse,"B",MaxTextExtent,format);
   (void) FormatLocaleFile(file,"  Pixels per second: %s\n",format);
   (void) FormatLocaleFile(file,"  User time: %0.3fu\n",user_time);
   (void) FormatLocaleFile(file,"  Elapsed time: %lu:%02lu.%03lu\n",
diff --git a/MagickCore/property.c b/MagickCore/property.c
index eb8ebc1..728b13a 100644
--- a/MagickCore/property.c
+++ b/MagickCore/property.c
@@ -2289,7 +2289,8 @@
     case 'b':  /* image size read in - in bytes */
     {
       WarnNoImageReturn("\"%%%c\"",letter);
-      (void) FormatMagickSize(image->extent,MagickFalse,"B",value);
+      (void) FormatMagickSize(image->extent,MagickFalse,"B",MaxTextExtent,
+        value);
       break;
     }
     case 'c':  /* image comment property - empty string by default */
@@ -2967,7 +2968,8 @@
       if (LocaleCompare("size",property) == 0)
         {
           WarnNoImageReturn("\"%%[%s]\"",property);
-          (void) FormatMagickSize(GetBlobSize(image),MagickFalse,"B",value);
+          (void) FormatMagickSize(GetBlobSize(image),MagickFalse,"B",
+            MaxTextExtent,value);
           break;
         }
       if (LocaleCompare("skewness",property) == 0)
diff --git a/MagickCore/resize.c b/MagickCore/resize.c
index b0a9c66..00ccc13 100644
--- a/MagickCore/resize.c
+++ b/MagickCore/resize.c
@@ -3704,7 +3704,8 @@
     }
   (void) FormatLocaleString(value,MaxTextExtent,"%.20g",(double)
     attributes.st_mtime);
-  (void) FormatMagickSize(GetBlobSize(image),MagickFalse,"B",value);
+  (void) FormatMagickSize(GetBlobSize(image),MagickFalse,"B",MaxTextExtent,
+    value);
   (void) SetImageProperty(thumbnail_image,"Thumb::Size",value,exception);
   (void) FormatLocaleString(value,MaxTextExtent,"image/%s",image->magick);
   LocaleLower(value);
diff --git a/MagickCore/resource.c b/MagickCore/resource.c
index 16c1979..d4eea9f 100644
--- a/MagickCore/resource.c
+++ b/MagickCore/resource.c
@@ -175,7 +175,7 @@
     limit;
 
   status=MagickFalse;
-  (void) FormatMagickSize(size,MagickFalse,"B",resource_request);
+  (void) FormatMagickSize(size,MagickFalse,"B",MaxTextExtent,resource_request);
   if (resource_semaphore == (SemaphoreInfo *) NULL)
     ActivateSemaphoreInfo(&resource_semaphore);
   LockSemaphoreInfo(resource_semaphore);
@@ -188,9 +188,9 @@
       status=(resource_info.area_limit == MagickResourceInfinity) ||
         (size < limit) ? MagickTrue : MagickFalse;
       (void) FormatMagickSize((MagickSizeType) resource_info.area,MagickFalse,
-        "B",resource_current);
-      (void) FormatMagickSize(resource_info.area_limit,MagickFalse,
-        "B",resource_limit);
+        "B",MaxTextExtent,resource_current);
+      (void) FormatMagickSize(resource_info.area_limit,MagickFalse,"B",
+        MaxTextExtent,resource_limit);
       break;
     }
     case MemoryResource:
@@ -201,9 +201,9 @@
         ((MagickSizeType) resource_info.memory < limit) ? MagickTrue :
         MagickFalse;
       (void) FormatMagickSize((MagickSizeType) resource_info.memory,MagickTrue,
-        "B",resource_current);
-      (void) FormatMagickSize(resource_info.memory_limit,MagickTrue,
-        "B",resource_limit);
+        "B",MaxTextExtent,resource_current);
+      (void) FormatMagickSize(resource_info.memory_limit,MagickTrue,"B",
+        MaxTextExtent,resource_limit);
       break;
     }
     case MapResource:
@@ -213,9 +213,9 @@
       status=(resource_info.map_limit == MagickResourceInfinity) ||
         ((MagickSizeType) resource_info.map < limit) ? MagickTrue : MagickFalse;
       (void) FormatMagickSize((MagickSizeType) resource_info.map,MagickTrue,
-        "B",resource_current);
+        "B",MaxTextExtent,resource_current);
       (void) FormatMagickSize(resource_info.map_limit,MagickTrue,
-        "B",resource_limit);
+        "B",MaxTextExtent,resource_limit);
       break;
     }
     case DiskResource:
@@ -226,9 +226,9 @@
         ((MagickSizeType) resource_info.disk < limit) ? MagickTrue :
         MagickFalse;
       (void) FormatMagickSize((MagickSizeType) resource_info.disk,MagickTrue,
-        "B",resource_current);
-      (void) FormatMagickSize(resource_info.disk_limit,MagickTrue,
-        "B",resource_limit);
+        "B",MaxTextExtent,resource_current);
+      (void) FormatMagickSize(resource_info.disk_limit,MagickTrue,"B",
+        MaxTextExtent,resource_limit);
       break;
     }
     case FileResource:
@@ -239,9 +239,9 @@
         ((MagickSizeType) resource_info.file < limit) ?
         MagickTrue : MagickFalse;
       (void) FormatMagickSize((MagickSizeType) resource_info.file,MagickFalse,
-        "B",resource_current);
+        "B",MaxTextExtent,resource_current);
       (void) FormatMagickSize((MagickSizeType) resource_info.file_limit,
-        MagickFalse,"B",resource_limit);
+        MagickFalse,"B",MaxTextExtent,resource_limit);
       break;
     }
     case HeightResource:
@@ -251,9 +251,9 @@
       status=(resource_info.area_limit == MagickResourceInfinity) ||
         (size < limit) ? MagickTrue : MagickFalse;
       (void) FormatMagickSize((MagickSizeType) resource_info.height,MagickFalse,
-        "P",resource_current);
+        "P",MaxTextExtent,resource_current);
       (void) FormatMagickSize(resource_info.height_limit,MagickFalse,
-        "P",resource_limit);
+        "P",MaxTextExtent,resource_limit);
       break;
     }
     case ThreadResource:
@@ -263,9 +263,9 @@
         ((MagickSizeType) resource_info.thread < limit) ?
         MagickTrue : MagickFalse;
       (void) FormatMagickSize((MagickSizeType) resource_info.thread,MagickFalse,
-        "B",resource_current);
+        "B",MaxTextExtent,resource_current);
       (void) FormatMagickSize((MagickSizeType) resource_info.thread_limit,
-        MagickFalse,"B",resource_limit);
+        MagickFalse,"B",MaxTextExtent,resource_limit);
       break;
     }
     case ThrottleResource:
@@ -275,9 +275,9 @@
         ((MagickSizeType) resource_info.throttle < limit) ?
         MagickTrue : MagickFalse;
       (void) FormatMagickSize((MagickSizeType) resource_info.throttle,
-        MagickFalse,"B",resource_current);
+        MagickFalse,"B",MaxTextExtent,resource_current);
       (void) FormatMagickSize((MagickSizeType) resource_info.throttle_limit,
-        MagickFalse,"B",resource_limit);
+        MagickFalse,"B",MaxTextExtent,resource_limit);
       break;
     }
     case TimeResource:
@@ -288,9 +288,9 @@
         ((MagickSizeType) resource_info.time < limit) ?
         MagickTrue : MagickFalse;
       (void) FormatMagickSize((MagickSizeType) resource_info.time,MagickFalse,
-        "B",resource_current);
+        "B",MaxTextExtent,resource_current);
       (void) FormatMagickSize((MagickSizeType) resource_info.time_limit,
-        MagickFalse,"B",resource_limit);
+        MagickFalse,"B",MaxTextExtent,resource_limit);
       break;
     }
     case WidthResource:
@@ -300,9 +300,9 @@
       status=(resource_info.area_limit == MagickResourceInfinity) ||
         (size < limit) ? MagickTrue : MagickFalse;
       (void) FormatMagickSize((MagickSizeType) resource_info.width,MagickFalse,
-        "P",resource_current);
-      (void) FormatMagickSize(resource_info.width_limit,MagickFalse,
-        "P",resource_limit);
+        "P",MaxTextExtent,resource_current);
+      (void) FormatMagickSize(resource_info.width_limit,MagickFalse,"P",
+        MaxTextExtent,resource_limit);
       break;
     }
     default:
@@ -783,16 +783,19 @@
     ActivateSemaphoreInfo(&resource_semaphore);
   LockSemaphoreInfo(resource_semaphore);
   (void) FormatMagickSize(resource_info.width_limit,MagickFalse,"P",
-    width_limit);
+    MaxTextExtent,width_limit);
   (void) FormatMagickSize(resource_info.height_limit,MagickFalse,"P",
-    height_limit);
-  (void) FormatMagickSize(resource_info.area_limit,MagickFalse,"B",area_limit);
+    MaxTextExtent,height_limit);
+  (void) FormatMagickSize(resource_info.area_limit,MagickFalse,"B",
+    MaxTextExtent,area_limit);
   (void) FormatMagickSize(resource_info.memory_limit,MagickTrue,"B",
-    memory_limit);
-  (void) FormatMagickSize(resource_info.map_limit,MagickTrue,"B",map_limit);
+    MaxTextExtent,memory_limit);
+  (void) FormatMagickSize(resource_info.map_limit,MagickTrue,"B",
+    MaxTextExtent,map_limit);
   (void) CopyMagickString(disk_limit,"unlimited",MaxTextExtent);
   if (resource_info.disk_limit != MagickResourceInfinity)
-    (void) FormatMagickSize(resource_info.disk_limit,MagickTrue,"B",disk_limit);
+    (void) FormatMagickSize(resource_info.disk_limit,MagickTrue,"B",
+      MaxTextExtent,disk_limit);
   (void) CopyMagickString(time_limit,"unlimited",MaxTextExtent);
   if (resource_info.time_limit != MagickResourceInfinity)
     (void) FormatLocaleString(time_limit,MaxTextExtent,"%.20g",(double)
@@ -849,7 +852,7 @@
     resource_limit[MaxTextExtent],
     resource_request[MaxTextExtent];
 
-  (void) FormatMagickSize(size,MagickFalse,"B",resource_request);
+  (void) FormatMagickSize(size,MagickFalse,"B",MaxTextExtent,resource_request);
   if (resource_semaphore == (SemaphoreInfo *) NULL)
 		ActivateSemaphoreInfo(&resource_semaphore);
   LockSemaphoreInfo(resource_semaphore);
@@ -859,88 +862,88 @@
     {
       resource_info.width=(MagickOffsetType) size;
       (void) FormatMagickSize((MagickSizeType) resource_info.width,MagickFalse,
-        "P",resource_current);
+        "P",MaxTextExtent,resource_current);
       (void) FormatMagickSize(resource_info.width_limit,MagickFalse,
-        "P",resource_limit);
+        "P",MaxTextExtent,resource_limit);
       break;
     }
     case HeightResource:
     {
       resource_info.width=(MagickOffsetType) size;
       (void) FormatMagickSize((MagickSizeType) resource_info.width,MagickFalse,
-        "P",resource_current);
+        "P",MaxTextExtent,resource_current);
       (void) FormatMagickSize(resource_info.width_limit,MagickFalse,
-        "P",resource_limit);
+        "P",MaxTextExtent,resource_limit);
       break;
     }
     case AreaResource:
     {
       resource_info.area=(MagickOffsetType) size;
       (void) FormatMagickSize((MagickSizeType) resource_info.area,MagickFalse,
-        "B",resource_current);
+        "B",MaxTextExtent,resource_current);
       (void) FormatMagickSize(resource_info.area_limit,MagickFalse,
-        "B",resource_limit);
+        "B",MaxTextExtent,resource_limit);
       break;
     }
     case MemoryResource:
     {
       resource_info.memory-=size;
       (void) FormatMagickSize((MagickSizeType) resource_info.memory,
-        MagickTrue,"B",resource_current);
+        MagickTrue,"B",MaxTextExtent,resource_current);
       (void) FormatMagickSize(resource_info.memory_limit,MagickTrue,
-        "B",resource_limit);
+        "B",MaxTextExtent,resource_limit);
       break;
     }
     case MapResource:
     {
       resource_info.map-=size;
       (void) FormatMagickSize((MagickSizeType) resource_info.map,MagickTrue,
-        "B",resource_current);
+        "B",MaxTextExtent,resource_current);
       (void) FormatMagickSize(resource_info.map_limit,MagickTrue,
-        "B",resource_limit);
+        "B",MaxTextExtent,resource_limit);
       break;
     }
     case DiskResource:
     {
       resource_info.disk-=size;
       (void) FormatMagickSize((MagickSizeType) resource_info.disk,MagickTrue,
-        "B",resource_current);
+        "B",MaxTextExtent,resource_current);
       (void) FormatMagickSize(resource_info.disk_limit,MagickTrue,
-        "B",resource_limit);
+        "B",MaxTextExtent,resource_limit);
       break;
     }
     case FileResource:
     {
       resource_info.file-=size;
       (void) FormatMagickSize((MagickSizeType) resource_info.file,MagickFalse,
-        "B",resource_current);
+        "B",MaxTextExtent,resource_current);
       (void) FormatMagickSize((MagickSizeType) resource_info.file_limit,
-        MagickFalse,"B",resource_limit);
+        MagickFalse,"B",MaxTextExtent,resource_limit);
       break;
     }
     case ThreadResource:
     {
       (void) FormatMagickSize((MagickSizeType) resource_info.thread,MagickFalse,
-        "B",resource_current);
+        "B",MaxTextExtent,resource_current);
       (void) FormatMagickSize((MagickSizeType) resource_info.thread_limit,
-        MagickFalse,"B",resource_limit);
+        MagickFalse,"B",MaxTextExtent,resource_limit);
       break;
     }
     case ThrottleResource:
     {
       (void) FormatMagickSize((MagickSizeType) resource_info.throttle,
-        MagickFalse,"B",resource_current);
+        MagickFalse,"B",MaxTextExtent,resource_current);
       (void) FormatMagickSize((MagickSizeType) resource_info.throttle_limit,
-        MagickFalse,"B",resource_limit);
+        MagickFalse,"B",MaxTextExtent,resource_limit);
       break;
     }
     case TimeResource:
     {
       resource_info.time-=size;
       (void) FormatMagickSize((MagickSizeType) resource_info.time,MagickFalse,
-        "B",resource_current);
+        "B",MaxTextExtent,resource_current);
       (void) FormatMagickSize((MagickSizeType) resource_info.time_limit,
-        MagickFalse,"B",resource_limit);
+        MagickFalse,"B",MaxTextExtent,resource_limit);
       break;
     }
     default:
diff --git a/MagickCore/string.c b/MagickCore/string.c
index 0705552..349c6bb 100644
--- a/MagickCore/string.c
+++ b/MagickCore/string.c
@@ -1059,7 +1059,7 @@
 %  The format of the FormatMagickSize method is:
 %
 %      ssize_t FormatMagickSize(const MagickSizeType size,const char *suffix,
-^        char *format)
+%        const size_t length,char *format)
 %
 %  A description of each parameter follows:
 %
@@ -1069,18 +1069,21 @@
 %
 %    o suffix:  append suffix, typically B or P.
 %
+%    o length: the maximum length of the string.
+%
 %    o format:  human readable format.
 %
 */
 MagickExport ssize_t FormatMagickSize(const MagickSizeType size,
-  const MagickBooleanType bi,const char *suffix,char *format)
+  const MagickBooleanType bi,const char *suffix,const size_t length,
+  char *format)
 {
   const char
     **units;
 
   double
     bytes,
-    length;
+    extent;
 
   register ssize_t
     i,
@@ -1107,21 +1110,21 @@
       units=bi_units;
     }
 #if defined(_MSC_VER) && (_MSC_VER == 1200)
-  length=(double) ((MagickOffsetType) size);
+  extent=(double) ((MagickOffsetType) size);
 #else
-  length=(double) size;
+  extent=(double) size;
 #endif
-  for (i=0; (length >= bytes) && (units[i+1] != (const char *) NULL); i++)
-    length/=bytes;
+  for (i=0; (extent >= bytes) && (units[i+1] != (const char *) NULL); i++)
+    extent/=bytes;
   count=0;
   for (j=2; j < 12; j++)
   {
     if (suffix == (const char *) NULL)
-      count=FormatLocaleString(format,MaxTextExtent,"%.*g%s",(int) (i+j),
-        length,units[i]);
+      count=FormatLocaleString(format,length,"%.*g%s",(int) (i+j),extent,
+        units[i]);
     else
-      count=FormatLocaleString(format,MaxTextExtent,"%.*g%s%s",(int) (i+j),
-        length,units[i],suffix);
+      count=FormatLocaleString(format,length,"%.*g%s%s",(int) (i+j),extent,
+        units[i],suffix);
     if (strchr(format,'+') == (char *) NULL)
       break;
   }
@@ -1149,12 +1152,12 @@
 %
 %  A description of each parameter follows.
 %
-%   o time:  the time since the Epoch (00:00:00 UTC, January 1, 1970),
-%     measured in seconds.
+%    o time:  the time since the Epoch (00:00:00 UTC, January 1, 1970),
+%      measured in seconds.
 %
-%   o length: the maximum length of the string.
+%    o length: the maximum length of the string.
 %
-%   o timestamp:  Return the Internet date/time here.
+%    o timestamp:  Return the Internet date/time here.
 %
 */
 MagickExport ssize_t FormatMagickTime(const time_t time,const size_t length,
diff --git a/MagickCore/string_.h b/MagickCore/string_.h
index efb8eef..9217187 100644
--- a/MagickCore/string_.h
+++ b/MagickCore/string_.h
@@ -79,7 +79,7 @@
 
 extern MagickExport ssize_t
   FormatMagickSize(const MagickSizeType,const MagickBooleanType,const char *,
-    char *),
+    const size_t,char *),
   FormatMagickTime(const time_t,const size_t,char *);
 
 extern MagickExport StringInfo
diff --git a/coders/json.c b/coders/json.c
index 0b8db16..ce1bb5e 100644
--- a/coders/json.c
+++ b/coders/json.c
@@ -1336,15 +1336,16 @@
     }
   (void) FormatLocaleFile(file,"  Tainted: %s\n",CommandOptionToMnemonic(
     MagickBooleanOptions,(ssize_t) image->taint));
-  (void) FormatMagickSize(GetBlobSize(image),MagickFalse,"B",format);
+  (void) FormatMagickSize(GetBlobSize(image),MagickFalse,"B",MaxTextExtent,
+    format);
   (void) FormatLocaleFile(file,"  Filesize: %s\n",format);
   (void) FormatMagickSize((MagickSizeType) image->columns*image->rows,
-    MagickFalse,"B",format);
+    MagickFalse,"B",MaxTextExtent,format);
   if (strlen(format) > 1)
     format[strlen(format)-1]='\0';
   (void) FormatLocaleFile(file,"  Number pixels: %s\n",format);
   (void) FormatMagickSize((MagickSizeType) ((double) image->columns*image->rows/
-    elapsed_time+0.5),MagickFalse,"B",format);
+    elapsed_time+0.5),MagickFalse,"B",MaxTextExtent,format);
   (void) FormatLocaleFile(file,"  Pixels per second: %s\n",format);
   (void) FormatLocaleFile(file,"  User time: %0.3fu\n",user_time);
   (void) FormatLocaleFile(file,"  Elapsed time: %lu:%02lu.%03lu\n",