From: markus schnalke Date: Wed, 28 Mar 2012 19:16:08 +0000 (+0200) Subject: Fixed programming mistakes, detected by cppcheck. X-Git-Tag: mmh-thesis-end~122 X-Git-Url: http://git.marmaro.de/?a=commitdiff_plain;h=dfecfa4b4b77983ddf8253b1b8effaf5c1a0ce80;p=mmh Fixed programming mistakes, detected by cppcheck. 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. ;-) ) --- diff --git a/sbr/folder_read.c b/sbr/folder_read.c index 8ccffc5..e4c1b7f 100644 --- a/sbr/folder_read.c +++ b/sbr/folder_read.c @@ -38,6 +38,7 @@ folder_read(char *name) if (stat(name, &st) == -1) { free(name); + closedir(dd); return NULL; } diff --git a/uip/inc.c b/uip/inc.c index ee51219..5142ae3 100644 --- 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) { diff --git a/uip/slocal.c b/uip/slocal.c index b83a268..765bcbd 100644 --- a/uip/slocal.c +++ b/uip/slocal.c @@ -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;