From ee9b196128db5c6a30918c795f5adcdd2adaca45 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Thu, 20 Dec 2007 11:15:38 +0000 Subject: bugfix: memory leak in cfsysline.c/doGetWord() fixed --- ChangeLog | 1 + cfsysline.c | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) 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)); -- cgit