summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2007-12-20 11:15:38 +0000
committerRainer Gerhards <rgerhards@adiscon.com>2007-12-20 11:15:38 +0000
commitee9b196128db5c6a30918c795f5adcdd2adaca45 (patch)
treea5f0ccc00834b1c83b73262c102cabeef85142d3
parent76007a666e17d9456cd7e3864f4e23223fae94c3 (diff)
downloadrsyslog-ee9b196128db5c6a30918c795f5adcdd2adaca45.tar.gz
rsyslog-ee9b196128db5c6a30918c795f5adcdd2adaca45.tar.xz
rsyslog-ee9b196128db5c6a30918c795f5adcdd2adaca45.zip
bugfix: memory leak in cfsysline.c/doGetWord() fixed
-rw-r--r--ChangeLog1
-rw-r--r--cfsysline.c11
2 files changed, 11 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index c34cd768..7bfa8fc2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,7 @@ Version 2.0.0 (rgerhards), 2007-12-??
parsing. Thanks to varmojfekoj for the patch.
- bugfix: when compiled without network support, unix sockets were
not properply closed
+- bugfix: memory leak in cfsysline.c/doGetWord() fixed
---------------------------------------------------------------------------
Version 1.21.0 (rgerhards), 2007-12-19
- GSS-API support for syslog/TCP connections was added. Thanks to
diff --git a/cfsysline.c b/cfsysline.c
index 14f50927..cf5def0a 100644
--- a/cfsysline.c
+++ b/cfsysline.c
@@ -353,6 +353,13 @@ finalize_it:
* a pointer to a string which is to receive the option
* value. The returned string must be freed by the caller.
* rgerhards, 2007-09-07
+ * To facilitate multiple instances of the same command line
+ * directive, doGetWord() now checks if pVal is already a
+ * non-NULL pointer. If so, we assume it was created by a previous
+ * incarnation and is automatically freed. This happens only when
+ * no custom handler is defined. If it is, the customer handler
+ * must do the cleanup. I have checked and this was al also memory
+ * leak with some code. Obviously, not a large one. -- rgerhards, 2007-12-20
*/
static rsRetVal doGetWord(uchar **pp, rsRetVal (*pSetHdlr)(void*, uchar*), void *pVal)
{
@@ -381,7 +388,9 @@ static rsRetVal doGetWord(uchar **pp, rsRetVal (*pSetHdlr)(void*, uchar*), void
/* we got the word, now set it */
if(pSetHdlr == NULL) {
/* we should set value directly to var */
- *((uchar**)pVal) = pNewVal;
+ if(pVal != NULL)
+ free(pVal); /* free previous entry */
+ *((uchar**)pVal) = pNewVal; /* set new one */
} else {
/* we set value via a set function */
CHKiRet(pSetHdlr(pVal, pNewVal));