diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2008-12-03 11:28:41 +0100 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2008-12-03 11:28:41 +0100 |
commit | b41bdeff56ad9d54dddcb8703560c750f04a6370 (patch) | |
tree | 01d0c63877678dd96aff9d0270252e40935dddbb /tcpsrv.c | |
parent | a7104880ee05722ad957b32824165561e7085ce8 (diff) | |
download | rsyslog-b41bdeff56ad9d54dddcb8703560c750f04a6370.tar.gz rsyslog-b41bdeff56ad9d54dddcb8703560c750f04a6370.tar.bz2 rsyslog-b41bdeff56ad9d54dddcb8703560c750f04a6370.zip |
bugfix: memory leak if sender was not permitted
Diffstat (limited to 'tcpsrv.c')
-rw-r--r-- | tcpsrv.c | 16 |
1 files changed, 10 insertions, 6 deletions
@@ -309,7 +309,7 @@ static rsRetVal SessAccept(tcpsrv_t *pThis, tcps_sess_t **ppSess, netstrm_t *pStrm) { DEFiRet; - tcps_sess_t *pSess; + tcps_sess_t *pSess = NULL; netstrm_t *pNewStrm = NULL; int iSess = -1; struct sockaddr_storage *addr; @@ -356,7 +356,9 @@ SessAccept(tcpsrv_t *pThis, tcps_sess_t **ppSess, netstrm_t *pStrm) * means we can finally fill in the session object. */ CHKiRet(tcps_sess.SetHost(pSess, fromHostFQDN)); + fromHostFQDN = NULL; /* we handed this string over */ CHKiRet(tcps_sess.SetHostIP(pSess, fromHostIP)); + fromHostIP = NULL; /* we handed this string over */ CHKiRet(tcps_sess.SetStrm(pSess, pNewStrm)); pNewStrm = NULL; /* prevent it from being freed in error handler, now done in tcps_sess! */ CHKiRet(tcps_sess.SetMsgIdx(pSess, 0)); @@ -369,14 +371,16 @@ SessAccept(tcpsrv_t *pThis, tcps_sess_t **ppSess, netstrm_t *pStrm) *ppSess = pSess; pThis->pSessions[iSess] = pSess; + pSess = NULL; /* this is now also handed over */ finalize_it: if(iRet != RS_RET_OK) { - if(iSess != -1) { - if(pThis->pSessions[iSess] != NULL) - tcps_sess.Destruct(&pThis->pSessions[iSess]); - } - iSess = -1; // TODO: change this to be fully iRet compliant ;) + if(pSess != NULL) + tcps_sess.Destruct(&pSess); + if(fromHostFQDN != NULL) + free(fromHostFQDN); + if(fromHostIP != NULL) + free(fromHostIP); if(pNewStrm != NULL) netstrm.Destruct(&pNewStrm); } |