summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2008-03-14 16:41:32 +0000
committerRainer Gerhards <rgerhards@adiscon.com>2008-03-14 16:41:32 +0000
commit38362e127f7b7b836332bf17097dbbae71bbe810 (patch)
tree34c59ca631a0101f061093edb551a5cfbe31d82f
parent8ed721578eb76a475d2da99212227ef8b62eee2f (diff)
downloadrsyslog-38362e127f7b7b836332bf17097dbbae71bbe810.tar.gz
rsyslog-38362e127f7b7b836332bf17097dbbae71bbe810.tar.xz
rsyslog-38362e127f7b7b836332bf17097dbbae71bbe810.zip
bugfix: memory leak in imfile
-rw-r--r--plugins/imfile/imfile.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/plugins/imfile/imfile.c b/plugins/imfile/imfile.c
index 91f90cc3..ea1b03ad 100644
--- a/plugins/imfile/imfile.c
+++ b/plugins/imfile/imfile.c
@@ -77,7 +77,8 @@ static int iFilPtr = 0; /* number of files to be monitored; pointer to next fre
static fileInfo_t files[MAX_INPUT_FILES];
-/* enqueue the read file line as a message
+/* enqueue the read file line as a message. The provided string is
+ * not freed - thuis must be done by the caller.
*/
static rsRetVal enqLine(fileInfo_t *pInfo, cstr_t *cstrLine)
{
@@ -171,7 +172,7 @@ finalize_it:
static rsRetVal pollFile(fileInfo_t *pThis, int *pbHadFileData)
{
DEFiRet;
- cstr_t *pCStr;
+ cstr_t *pCStr = NULL;
ASSERT(pbHadFileData != NULL);
@@ -184,9 +185,14 @@ static rsRetVal pollFile(fileInfo_t *pThis, int *pbHadFileData)
CHKiRet(strmReadLine(pThis->pStrm, &pCStr));
*pbHadFileData = 1; /* this is just a flag, so set it and forget it */
CHKiRet(enqLine(pThis, pCStr)); /* process line */
+ rsCStrDestruct(&pCStr); /* discard string (must be done by us!) */
}
finalize_it:
+ if(pCStr != NULL) {
+ rsCStrDestruct(&pCStr);
+ }
+
RETiRet;
}