From 79c68ff64cd50f71322e748b136a51073d5b3a03 Mon Sep 17 00:00:00 2001 From: Bill Nottingham Date: Thu, 31 Mar 2005 21:39:44 +0000 Subject: free some of the more egregious memory leaks (#85935) --- src/initlog.c | 24 +++++++++++++++++------- src/process.c | 10 ++++++++-- 2 files changed, 25 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/initlog.c b/src/initlog.c index 3b1cded6..19d9f9aa 100644 --- a/src/initlog.c +++ b/src/initlog.c @@ -51,7 +51,7 @@ struct logInfo *logData = NULL; void readConfiguration(char *fname) { int fd,num=0; struct stat sbuf; - char *data,*line; + char *data,*line, *d; regex_t *regexp; int lfac=-1,lpri=-1; @@ -60,7 +60,7 @@ void readConfiguration(char *fname) { close(fd); return; } - data=malloc(sbuf.st_size+1); + d = data=malloc(sbuf.st_size+1); if (read(fd,data,sbuf.st_size)!=sbuf.st_size) { close(fd); free(data); @@ -110,6 +110,7 @@ void readConfiguration(char *fname) { } if (lfac!=-1) logfacility=lfac; if (lpri!=-1) logpriority=lpri; + free(d); } char *getLine(char **data) { @@ -279,7 +280,7 @@ int logEvent(char *cmd, int eventtype,char *string) { /* insert more here */ NULL }; - int x=0,len; + int x=0,len, rc; struct logInfo logentry; if (cmd) { @@ -290,8 +291,10 @@ int logEvent(char *cmd, int eventtype,char *string) { logentry.cmd+=3; } else logentry.cmd = strdup(_("(none)")); - if (!string) - string = strdup(cmd); + if (!string) { + string = alloca(strlen(cmd)+1); + strcpy(string,cmd); + } while (eventtable[x] && x