Fixed programming mistakes, detected by cppcheck.
authormarkus schnalke <meillo@marmaro.de>
Wed, 28 Mar 2012 19:16:08 +0000 (21:16 +0200)
committermarkus schnalke <meillo@marmaro.de>
Wed, 28 Mar 2012 19:16:08 +0000 (21:16 +0200)
Two memory leaks and a possibly not terminated string.
(There also is a false positive in sbr/path.c.)
(sbr/dtimep.c has warnings, but I believe lex is correct. ;-) )

sbr/folder_read.c
uip/inc.c
uip/slocal.c

index 8ccffc5..e4c1b7f 100644 (file)
@@ -38,6 +38,7 @@ folder_read(char *name)
 
        if (stat(name, &st) == -1) {
                free(name);
+               closedir(dd);
                return NULL;
        }
 
index ee51219..5142ae3 100644 (file)
--- a/uip/inc.c
+++ b/uip/inc.c
@@ -437,6 +437,7 @@ main(int argc, char **argv)
                */
                break;
        }
+       free(maildir_copy);
 
        if (incerr < 0) {  /* error */
                if (locked) {
index b83a268..765bcbd 100644 (file)
@@ -1107,6 +1107,7 @@ get_sender(char *envelope, char **sender)
 
        i = strlen("From ");
        strncpy(buffer, envelope + i, sizeof(buffer));
+       buffer[sizeof buffer -1] = '\0';  /* ensure termination */
        if ((cp = strchr(buffer, '\n'))) {
                *cp = '\0';
                cp -= 24;