From dfecfa4b4b77983ddf8253b1b8effaf5c1a0ce80 Mon Sep 17 00:00:00 2001 From: markus schnalke Date: Wed, 28 Mar 2012 21:16:08 +0200 Subject: [PATCH] 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. ;-) ) --- sbr/folder_read.c | 1 + uip/inc.c | 1 + uip/slocal.c | 1 + 3 files changed, 3 insertions(+) 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; -- 1.7.10.4