mirror of
https://github.com/rsyslog/rsyslog.git
synced 2026-08-30 22:10:18 +02: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)
|
SessAccept(tcpsrv_t *pThis, tcps_sess_t **ppSess, netstrm_t *pStrm)
|
||||||
{
|
{
|
||||||
DEFiRet;
|
DEFiRet;
|
||||||
tcps_sess_t *pSess;
|
tcps_sess_t *pSess = NULL;
|
||||||
netstrm_t *pNewStrm = NULL;
|
netstrm_t *pNewStrm = NULL;
|
||||||
int iSess = -1;
|
int iSess = -1;
|
||||||
struct sockaddr_storage *addr;
|
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.
|
* means we can finally fill in the session object.
|
||||||
*/
|
*/
|
||||||
CHKiRet(tcps_sess.SetHost(pSess, fromHostFQDN));
|
CHKiRet(tcps_sess.SetHost(pSess, fromHostFQDN));
|
||||||
|
fromHostFQDN = NULL; /* we handed this string over */
|
||||||
CHKiRet(tcps_sess.SetHostIP(pSess, fromHostIP));
|
CHKiRet(tcps_sess.SetHostIP(pSess, fromHostIP));
|
||||||
|
fromHostIP = NULL; /* we handed this string over */
|
||||||
CHKiRet(tcps_sess.SetStrm(pSess, pNewStrm));
|
CHKiRet(tcps_sess.SetStrm(pSess, pNewStrm));
|
||||||
pNewStrm = NULL; /* prevent it from being freed in error handler, now done in tcps_sess! */
|
pNewStrm = NULL; /* prevent it from being freed in error handler, now done in tcps_sess! */
|
||||||
CHKiRet(tcps_sess.SetMsgIdx(pSess, 0));
|
CHKiRet(tcps_sess.SetMsgIdx(pSess, 0));
|
||||||
@ -369,14 +371,16 @@ SessAccept(tcpsrv_t *pThis, tcps_sess_t **ppSess, netstrm_t *pStrm)
|
|||||||
|
|
||||||
*ppSess = pSess;
|
*ppSess = pSess;
|
||||||
pThis->pSessions[iSess] = pSess;
|
pThis->pSessions[iSess] = pSess;
|
||||||
|
pSess = NULL; /* this is now also handed over */
|
||||||
|
|
||||||
finalize_it:
|
finalize_it:
|
||||||
if(iRet != RS_RET_OK) {
|
if(iRet != RS_RET_OK) {
|
||||||
if(iSess != -1) {
|
if(pSess != NULL)
|
||||||
if(pThis->pSessions[iSess] != NULL)
|
tcps_sess.Destruct(&pSess);
|
||||||
tcps_sess.Destruct(&pThis->pSessions[iSess]);
|
if(fromHostFQDN != NULL)
|
||||||
}
|
free(fromHostFQDN);
|
||||||
iSess = -1; // TODO: change this to be fully iRet compliant ;)
|
if(fromHostIP != NULL)
|
||||||
|
free(fromHostIP);
|
||||||
if(pNewStrm != NULL)
|
if(pNewStrm != NULL)
|
||||||
netstrm.Destruct(&pNewStrm);
|
netstrm.Destruct(&pNewStrm);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user