]> diplodocus.org Git - nmh/commitdiff
Fixed some of the issues noted by clang --analyze with
authorDavid Levine <levinedl@acm.org>
Sat, 15 Mar 2014 01:25:06 +0000 (20:25 -0500)
committerDavid Levine <levinedl@acm.org>
Sat, 15 Mar 2014 01:25:06 +0000 (20:25 -0500)
mhfixmsg.c and mkstemp.c.

uip/mhfixmsg.c
uip/mkstemp.c

index f00fc97d06a71f5329f4270991abefe14515cb02..7fd69f50abc4e90139f924d5cd5be2723651654b 100644 (file)
@@ -563,10 +563,11 @@ get_multipart_boundary (CT ct, char **part_boundary) {
     while (begin >= (off_t) ct->c_begin) {
         fseeko (ct->c_fp, begin, SEEK_SET);
         while ((bytes_read = fread (buffer, 1, sizeof buffer, ct->c_fp)) > 0) {
     while (begin >= (off_t) ct->c_begin) {
         fseeko (ct->c_fp, begin, SEEK_SET);
         while ((bytes_read = fread (buffer, 1, sizeof buffer, ct->c_fp)) > 0) {
-            char *end = buffer + bytes_read - 1;
-            char *cp;
+            char *cp = rfind_str (buffer, bytes_read, "--");
+
+            if (cp) {
+                char *end;
 
 
-            if ((cp = rfind_str (buffer, bytes_read, "--"))) {
                 /* Trim off trailing "--" and anything beyond. */
                 *cp-- = '\0';
                 if ((end = rfind_str (buffer, cp - buffer, "\n"))) {
                 /* Trim off trailing "--" and anything beyond. */
                 *cp-- = '\0';
                 if ((end = rfind_str (buffer, cp - buffer, "\n"))) {
@@ -1222,6 +1223,7 @@ build_multipart_alt (CT first_alt, CT new_part, int type, int subtype) {
                      boundary_in_content (&new_part->c_cefile.ce_fp,
                                           new_part->c_cefile.ce_file,
                                           boundary)) == -1) {
                      boundary_in_content (&new_part->c_cefile.ce_fp,
                                           new_part->c_cefile.ce_file,
                                           boundary)) == -1) {
+                    free (ct);
                     return NULL;
                 }
             }
                     return NULL;
                 }
             }
@@ -1232,6 +1234,7 @@ build_multipart_alt (CT first_alt, CT new_part, int type, int subtype) {
                 if ((found_boundary = boundary_in_content (&new_part->c_fp,
                                                            new_part->c_file,
                                                            boundary)) == -1) {
                 if ((found_boundary = boundary_in_content (&new_part->c_fp,
                                                            new_part->c_file,
                                                            boundary)) == -1) {
+                    free (ct);
                     return NULL;
                 }
             }
                     return NULL;
                 }
             }
@@ -1252,6 +1255,7 @@ build_multipart_alt (CT first_alt, CT new_part, int type, int subtype) {
 
         if (found_boundary) {
             advise (NULL, "giving up trying to find a unique boundary");
 
         if (found_boundary) {
             advise (NULL, "giving up trying to find a unique boundary");
+            free (ct);
             return NULL;
         }
     }
             return NULL;
         }
     }
index d594c3621313f3da0ff829c87b7551787c752cf9..8139fec789b4c5714158a8c50ee9aef9271ee4fa 100644 (file)
@@ -104,7 +104,7 @@ build_template(const char *directory, const char *prefix, const char *suffix) {
         tp += sizeof pattern - 1;
 
         (void) strncpy(tp, suffix, suffix_len);
         tp += sizeof pattern - 1;
 
         (void) strncpy(tp, suffix, suffix_len);
-        tp += suffix_len;
+        /* tp += suffix_len; */
 
         template[len-1] = '\0';
 
 
         template[len-1] = '\0';