summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2008-03-27 14:58:53 +0000
committerRainer Gerhards <rgerhards@adiscon.com>2008-03-27 14:58:53 +0000
commit94e32990ee01bc7622909f40f0839bc4516cd56d (patch)
tree1e8fb76d82abc479dcffea3e2f6a894245a012ab /plugins
parent0f3da7e4b38470b35b5a1b28992c78d57c2fcaa5 (diff)
downloadrsyslog-94e32990ee01bc7622909f40f0839bc4516cd56d.tar.gz
rsyslog-94e32990ee01bc7622909f40f0839bc4516cd56d.tar.xz
rsyslog-94e32990ee01bc7622909f40f0839bc4516cd56d.zip
fixed memory leaks in stream class and imfile
Diffstat (limited to 'plugins')
-rw-r--r--plugins/imfile/imfile.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/plugins/imfile/imfile.c b/plugins/imfile/imfile.c
index a6e019d6..162cab9f 100644
--- a/plugins/imfile/imfile.c
+++ b/plugins/imfile/imfile.c
@@ -168,6 +168,17 @@ finalize_it:
}
+/* The following is a cancel cleanup handler for strmReadLine(). It is necessary in case
+ * strmReadLine() is cancelled while processing the stream. -- rgerhards, 2008-03-27
+ */
+static void pollFileCancelCleanup(void *pArg)
+{
+ BEGINfunc;
+ cstr_t **ppCStr = (cstr_t**) pArg;
+ if(*ppCStr != NULL)
+ rsCStrDestruct(ppCStr);
+ ENDfunc;
+}
/* poll a file, need to check file rollover etc. open file if not open */
static rsRetVal pollFile(fileInfo_t *pThis, int *pbHadFileData)
{
@@ -180,6 +191,7 @@ static rsRetVal pollFile(fileInfo_t *pThis, int *pbHadFileData)
CHKiRet(openFile(pThis)); /* open file */
}
+ pthread_cleanup_push(pollFileCancelCleanup, &pCStr);
/* loop below will be exited when strmReadLine() returns EOF */
while(1) {
CHKiRet(strmReadLine(pThis->pStrm, &pCStr));
@@ -187,6 +199,7 @@ static rsRetVal pollFile(fileInfo_t *pThis, int *pbHadFileData)
CHKiRet(enqLine(pThis, pCStr)); /* process line */
rsCStrDestruct(&pCStr); /* discard string (must be done by us!) */
}
+ pthread_cleanup_pop(0);
finalize_it:
if(pCStr != NULL) {
@@ -333,6 +346,9 @@ persistStrmState(fileInfo_t *pInfo)
CHKiRet(strmDestruct(&psSF));
finalize_it:
+ if(psSF != NULL)
+ strmDestruct(&psSF);
+
RETiRet;
}