summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2007-08-09 12:56:33 +0000
committerRainer Gerhards <rgerhards@adiscon.com>2007-08-09 12:56:33 +0000
commit2b5dc260a55b81f4a991254f1b7549342a11db0b (patch)
treed49448d6026d499cb5e4dda015948f3764bbb5bf
parentd98436bbbaf29ee3cbdd01ffbb66bf21b0ef4cdb (diff)
downloadrsyslog-2b5dc260a55b81f4a991254f1b7549342a11db0b.tar.gz
rsyslog-2b5dc260a55b81f4a991254f1b7549342a11db0b.tar.xz
rsyslog-2b5dc260a55b81f4a991254f1b7549342a11db0b.zip
fixed a bug that would have manifested when module configuration commands
would have been freed. The current code base, however, never does this, so this is not a real bug fix - it's in preparation of future work
-rw-r--r--cfsysline.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/cfsysline.c b/cfsysline.c
index 14b113cb..fcbf1392 100644
--- a/cfsysline.c
+++ b/cfsysline.c
@@ -527,10 +527,15 @@ finalize_it:
/* function that registers cfsysline handlers.
+ * The supplied pCmdName is copied and a new buffer is allocated. This
+ * buffer is automatically destroyed when the element is freed, the
+ * caller does not need to take care of that. The caller must, however,
+ * free pCmdName if he allocated it dynamically! -- rgerhards, 2007-08-09
*/
rsRetVal regCfSysLineHdlr(uchar *pCmdName, int bChainingPermitted, ecslCmdHdrlType eType, rsRetVal (*pHdlr)(), void *pData)
{
cslCmd_t *pThis;
+ uchar *pMyCmdName;
DEFiRet;
iRet = llFind(&llCmdList, (void *) pCmdName, (void**) &pThis);
@@ -544,7 +549,11 @@ rsRetVal regCfSysLineHdlr(uchar *pCmdName, int bChainingPermitted, ecslCmdHdrlTy
/* important: add to list, AFTER everything else is OK. Else
* we mess up things in the error case.
*/
- CHKiRet_Hdlr(llAppend(&llCmdList, pCmdName, (void*) pThis)) {
+ if((pMyCmdName = (uchar*) strdup((char*)pCmdName)) == NULL) {
+ cslcDestruct(pThis);
+ ABORT_FINALIZE(RS_RET_OUT_OF_MEMORY);
+ }
+ CHKiRet_Hdlr(llAppend(&llCmdList, pMyCmdName, (void*) pThis)) {
cslcDestruct(pThis);
goto finalize_it;
}