summaryrefslogtreecommitdiffstats
path: root/runtime/stream.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2011-05-21 04:29:53 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2011-05-21 04:29:53 +0200
commit780e2d37e4d27f040d15e09b25542d6808a19436 (patch)
treeed63ad693d64961c3db56a423827e83e9760b156 /runtime/stream.c
parent503dec99f2e21fba336c989b209fadbf201e6f7e (diff)
parent715b9fe052f5a7c622a1f71f905461e06e398de8 (diff)
downloadrsyslog-780e2d37e4d27f040d15e09b25542d6808a19436.tar.gz
rsyslog-780e2d37e4d27f040d15e09b25542d6808a19436.tar.bz2
rsyslog-780e2d37e4d27f040d15e09b25542d6808a19436.zip
Merge branch 'beta'
Conflicts: ChangeLog plugins/imrelp/imrelp.c
Diffstat (limited to 'runtime/stream.c')
-rw-r--r--runtime/stream.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/runtime/stream.c b/runtime/stream.c
index 24dbcc09..ae716815 100644
--- a/runtime/stream.c
+++ b/runtime/stream.c
@@ -259,6 +259,7 @@ static rsRetVal strmOpenFile(strm_t *pThis)
if(pThis->fd != -1)
ABORT_FINALIZE(RS_RET_OK);
+ pThis->pszCurrFName = NULL; /* used to prevent mem leak in case of error */
if(pThis->pszFName == NULL)
ABORT_FINALIZE(RS_RET_FILE_PREFIX_MISSING);
@@ -290,6 +291,16 @@ static rsRetVal strmOpenFile(strm_t *pThis)
(pThis->tOperationsMode == STREAMMODE_READ) ? "READ" : "WRITE", pThis->fd);
finalize_it:
+ if(iRet != RS_RET_OK) {
+ if(pThis->pszCurrFName != NULL) {
+ free(pThis->pszCurrFName);
+ pThis->pszCurrFName = NULL; /* just to prevent mis-adressing down the road... */
+ }
+ if(pThis->fd != -1) {
+ close(pThis->fd);
+ pThis->fd = -1;
+ }
+ }
RETiRet;
}