From 2b5dc260a55b81f4a991254f1b7549342a11db0b Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Thu, 9 Aug 2007 12:56:33 +0000 Subject: 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 --- cfsysline.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'cfsysline.c') 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; } -- cgit