summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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));