diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2011-06-14 12:52:02 +0200 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2011-06-14 12:52:02 +0200 |
commit | bcd956d4d500040808b920e468529da94a1e33c8 (patch) | |
tree | 30dc8ac23c848c69a9e06173b0ace544a2c93ac7 /tcpsrv.c | |
parent | f847c2dda32488034f252e3bbd1a267714b99ff0 (diff) | |
download | rsyslog-bcd956d4d500040808b920e468529da94a1e33c8.tar.gz rsyslog-bcd956d4d500040808b920e468529da94a1e33c8.tar.xz rsyslog-bcd956d4d500040808b920e468529da94a1e33c8.zip |
bugfix: memory leak in imtcp & subsystems under some circumstances
This leak is tied to error conditions which lead to incorrect cleanup
of some data structures. [backport from v6, limited testing under v4]
Diffstat (limited to 'tcpsrv.c')
-rw-r--r-- | tcpsrv.c | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -477,7 +477,7 @@ Run(tcpsrv_t *pThis) int iTCPSess; int bIsReady; tcps_sess_t *pNewSess; - nssel_t *pSel; + nssel_t *pSel = NULL; ssize_t iRcvd; ISOBJ_TYPE_assert(pThis, tcpsrv); @@ -521,8 +521,8 @@ Run(tcpsrv_t *pThis) /* now check the sessions */ iTCPSess = TCPSessGetNxtSess(pThis, -1); while(nfds && iTCPSess != -1) { - CHKiRet(nssel.IsReady(pSel, pThis->pSessions[iTCPSess]->pStrm, NSDSEL_RD, &bIsReady, &nfds)); - if(bIsReady) { + localRet = nssel.IsReady(pSel, pThis->pSessions[iTCPSess]->pStrm, NSDSEL_RD, &bIsReady, &nfds); + if(bIsReady || localRet != RS_RET_OK) { char buf[128*1024]; /* reception buffer - may hold a partial or multiple messages */ dbgprintf("netstream %p with new data\n", pThis->pSessions[iTCPSess]->pStrm); @@ -576,7 +576,9 @@ finalize_it: /* this is a very special case - this time only we do not exit the * crashed, which made sense (the rest of the engine was not prepared for * that) -- rgerhards, 2008-05-19 */ - /*EMPTY*/; + if(pSel != NULL) { /* cleanup missing? happens during err exit! */ + nssel.Destruct(&pSel); + } } /* note that this point is usually not reached */ |