]> granicus.if.org Git - neomutt/commitdiff
check size_t value
authorRichard Russon <rich@flatcap.org>
Wed, 17 Jan 2018 14:33:51 +0000 (14:33 +0000)
committerRichard Russon <rich@flatcap.org>
Thu, 18 Jan 2018 23:26:51 +0000 (23:26 +0000)
parse.c

diff --git a/parse.c b/parse.c
index 4b79963c749bffecefe98abb6b8229c06f4d2bca..df3a27a6e994438d576ee933ca0ba5c8d8657ab4 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -617,9 +617,12 @@ struct Body *mutt_parse_multipart(FILE *fp, const char *boundary, LOFF_T end_off
           last->length = 0;
       }
 
-      /* Remove any trailing whitespace, up to the length of the boundary */
-      for (size_t i = len - 1; ISSPACE(buffer[i]) && i >= blen + 2; i--)
-        buffer[i] = 0;
+      if (len > 0)
+      {
+        /* Remove any trailing whitespace, up to the length of the boundary */
+        for (size_t i = len - 1; ISSPACE(buffer[i]) && i >= blen + 2; i--)
+          buffer[i] = 0;
+      }
 
       /* Check for the end boundary */
       if (mutt_str_strcmp(buffer + blen + 2, "--") == 0)