summaryrefslogtreecommitdiff
path: root/runtime/stream.c
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2011-05-19 22:53:09 +0200
committerMichael Biebl <biebl@debian.org>2011-05-19 22:53:09 +0200
commit734f0031f3366c83552de8b0e628949d47ff9487 (patch)
tree75cb2c0985c21bc7ffd6d06e94ec7fb420f2a1c4 /runtime/stream.c
parent2e96de39e5394008f97d6c194e507e629d836738 (diff)
downloadrsyslog-734f0031f3366c83552de8b0e628949d47ff9487.tar.gz
Imported Upstream version 5.8.1upstream/5.8.1
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 24dbcc0..ae71681 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;
}