mirror of
https://github.com/rsyslog/rsyslog.git
synced 2025-12-19 23:10:41 +01:00
bugfix: memory leak if sender was not permitted
This commit is contained in:
parent
a7104880ee
commit
b41bdeff56
16
tcpsrv.c
16
tcpsrv.c
@ -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);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user