diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2008-06-04 09:37:10 +0200 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2008-06-04 09:37:10 +0200 |
commit | 99e97dadf1d03c9db33d49e91b26ceb28a39ed1a (patch) | |
tree | 6c4d24be3eb4bfd37f2fdd4770be0abeb865791e /tools | |
parent | 67d4f3c8f39f22a61ab9097163081d1a31e8d5a9 (diff) | |
download | rsyslog-99e97dadf1d03c9db33d49e91b26ceb28a39ed1a.tar.gz rsyslog-99e97dadf1d03c9db33d49e91b26ceb28a39ed1a.tar.xz rsyslog-99e97dadf1d03c9db33d49e91b26ceb28a39ed1a.zip |
bugfix: removed some memory leaks in TLS code
Diffstat (limited to 'tools')
-rw-r--r-- | tools/omfwd.c | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/tools/omfwd.c b/tools/omfwd.c index f8ed81dc..317bc298 100644 --- a/tools/omfwd.c +++ b/tools/omfwd.c @@ -117,6 +117,22 @@ static char *getFwdPt(instanceData *pData) return(pData->port); } + +/* destruct the TCP helper objects + * This, for example, is needed after something went wrong. + * This function is void because it "can not" fail. + * rgerhards, 2008-06-04 + */ +static inline void +DestructTCPInstanceData(instanceData *pData) +{ + assert(pData != NULL); + if(pData->pNetstrm != NULL) + netstrm.Destruct(&pData->pNetstrm); + if(pData->pNS != NULL) + netstrms.Destruct(&pData->pNS); +} + BEGINcreateInstance CODESTARTcreateInstance ENDcreateInstance @@ -139,8 +155,7 @@ CODESTARTfreeInstance free(pData->port); /* final cleanup */ - if(pData->pNetstrm != NULL) - netstrm.Destruct(&pData->pNetstrm); + DestructTCPInstanceData(pData); if(pData->pSockArray != NULL) net.closeUDPListenSockets(pData->pSockArray); @@ -219,6 +234,7 @@ setPermittedPeer(void __attribute__((unused)) *pVal, uchar *pszID) { DEFiRet; CHKiRet(net.AddPermittedPeer(&pPermPeers, pszID)); + free(pszID); /* no longer needed, but we must free it as of interface def */ finalize_it: RETiRet; } @@ -266,7 +282,7 @@ static rsRetVal TCPSendPrepRetry(void *pvData) instanceData *pData = (instanceData *) pvData; assert(pData != NULL); - netstrm.Destruct(&pData->pNetstrm); + DestructTCPInstanceData(pData); RETiRet; } @@ -304,10 +320,7 @@ static rsRetVal TCPSendInit(void *pvData) finalize_it: if(iRet != RS_RET_OK) { - if(pData->pNetstrm != NULL) - netstrm.Destruct(&pData->pNetstrm); - if(pData->pNS != NULL) - netstrms.Destruct(&pData->pNS); + DestructTCPInstanceData(pData); } RETiRet; @@ -426,6 +439,7 @@ CODESTARTdoAction if(ret != RS_RET_OK) { /* error! */ dbgprintf("error forwarding via tcp, suspending\n"); + DestructTCPInstanceData(pData); iRet = RS_RET_SUSPENDED; } } |