summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog3
-rw-r--r--grammar/lexer.l4
-rw-r--r--runtime/rule.c2
-rw-r--r--template.c16
-rw-r--r--tests/Makefile.am3
-rwxr-xr-xtests/rscript_contains.sh13
-rw-r--r--tests/testsuites/rscript_contains.conf4
7 files changed, 34 insertions, 11 deletions
diff --git a/ChangeLog b/ChangeLog
index ef3eb344..b817b729 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -50,6 +50,9 @@ Version 6.5.1 [devel] 2012-08-??
used \x as escape where x was any character (e.g. "\n" meant "n" and NOT
LF). This also means there is some incompatibility to v5 for well-know
sequences. Better break it now than later.
+- bugfix: small memory leaks in template() statements
+ these were one-time memory leaks during startup, so they did NOT grow
+ during runtime
---------------------------------------------------------------------------
Version 6.5.0 [devel] 2012-08-28
- imrelp now supports non-cancel thread termination
diff --git a/grammar/lexer.l b/grammar/lexer.l
index 7f42b04e..657c817f 100644
--- a/grammar/lexer.l
+++ b/grammar/lexer.l
@@ -127,12 +127,12 @@ int fileno(FILE *stream);
<EXPR>\'([^'\\]|\\['"\\$bntr]|\\x[0-9a-f][0-9a-f]|\\[0-7][0-7][0-7])*\' {
yytext[yyleng-1] = '\0';
unescapeStr((uchar*)yytext+1, yyleng-2);
- yylval.estr = es_newStrFromBuf(yytext+1, strlen(yytext));
+ yylval.estr = es_newStrFromBuf(yytext+1, strlen(yytext)-1);
return STRING; }
<EXPR>\"([^"\\$]|\\["'\\$bntr]|\\x[0-9a-f][0-9a-f]|\\[0-7][0-7][0-7])*\" {
yytext[yyleng-1] = '\0';
unescapeStr((uchar*)yytext+1, yyleng-2);
- yylval.estr = es_newStrFromBuf(yytext+1, yyleng-2);
+ yylval.estr = es_newStrFromBuf(yytext+1, strlen(yytext)-1);
return STRING; }
<EXPR>[ \t\n]
<EXPR>[a-z][a-z0-9_]* { yylval.estr = es_newStrFromCStr(yytext, yyleng);
diff --git a/runtime/rule.c b/runtime/rule.c
index f6160bdc..fe3d2ed8 100644
--- a/runtime/rule.c
+++ b/runtime/rule.c
@@ -173,12 +173,12 @@ shouldProcessThisMessage(rule_t *pRule, msg_t *pMsg, sbool *bProcessMsg)
if(pRule->f_filter_type == FILTER_PRI) {
/* skip messages that are incorrect priority */
- DBGPRINTF("testing filter, f_pmask %d\n", pRule->f_filterData.f_pmask[pMsg->iFacility]);
if ( (pRule->f_filterData.f_pmask[pMsg->iFacility] == TABLE_NOPRI) || \
((pRule->f_filterData.f_pmask[pMsg->iFacility] & (1<<pMsg->iSeverity)) == 0) )
bRet = 0;
else
bRet = 1;
+ DBGPRINTF("testing filter, f_pmask %d, result %d\n", pRule->f_filterData.f_pmask[pMsg->iFacility], bRet);
} else if(pRule->f_filter_type == FILTER_EXPR) {
bRet = cnfexprEvalBool(pRule->f_filterData.expr, pMsg);
DBGPRINTF("result of rainerscript filter evaluation: %d\n", bRet);
diff --git a/template.c b/template.c
index 3cef586c..15d376a3 100644
--- a/template.c
+++ b/template.c
@@ -1256,7 +1256,7 @@ createConstantTpe(struct template *pTpl, struct cnfobj *o)
struct templateEntry *pTpe;
es_str_t *value;
int i;
- struct cnfparamvals *pvals;
+ struct cnfparamvals *pvals = NULL;
uchar *outname = NULL;
DEFiRet;
@@ -1290,6 +1290,8 @@ createConstantTpe(struct template *pTpl, struct cnfobj *o)
pTpe->data.constant.pConstant = (uchar*)es_str2cstr(value, NULL);
finalize_it:
+ if(pvals != NULL)
+ cnfparamvalsDestruct(pvals, &pblkConstant);
RETiRet;
}
@@ -1310,7 +1312,7 @@ createPropertyTpe(struct template *pTpl, struct cnfobj *o)
int re_matchToUse = 0;
int re_submatchToUse = 0;
char *re_expr = NULL;
- struct cnfparamvals *pvals;
+ struct cnfparamvals *pvals = NULL;
enum {F_NONE, F_CSV, F_JSON, F_JSONF} formatType = F_NONE;
enum {CC_NONE, CC_ESCAPE, CC_SPACE, CC_DROP} controlchr = CC_NONE;
enum {SP_NONE, SP_DROP, SP_REPLACE} secpath = SP_NONE;
@@ -1328,12 +1330,10 @@ createPropertyTpe(struct template *pTpl, struct cnfobj *o)
if(!pvals[i].bUsed)
continue;
if(!strcmp(pblkProperty.descr[i].name, "name")) {
- char *tmp;
-
- tmp = es_str2cstr(pvals[i].val.d.estr, NULL);
- rsCStrConstructFromszStr(&name, (uchar*)tmp);
+ uchar *tmpstr = (uchar*)es_str2cstr(pvals[i].val.d.estr, NULL);
+ rsCStrConstructFromszStr(&name, tmpstr);
cstrFinalize(name);
- free(tmp);
+ free(tmpstr);
} else if(!strcmp(pblkProperty.descr[i].name, "droplastlf")) {
droplastlf = pvals[i].val.d.n;
} else if(!strcmp(pblkProperty.descr[i].name, "mandatory")) {
@@ -1622,7 +1622,7 @@ rsRetVal
tplProcessCnf(struct cnfobj *o)
{
struct template *pTpl = NULL;
- struct cnfparamvals *pvals;
+ struct cnfparamvals *pvals = NULL;
int lenName;
char *name = NULL;
uchar *tplStr = NULL;
diff --git a/tests/Makefile.am b/tests/Makefile.am
index c4560445..a9369929 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -64,6 +64,7 @@ TESTS += \
failover-no-rptd.sh \
failover-no-basic.sh \
rcvr_fail_restore.sh \
+ rscript_contains.sh \
linkedlistqueue.sh
if HAVE_VALGRIND
@@ -264,6 +265,8 @@ EXTRA_DIST= 1.rstest 2.rstest 3.rstest err1.rstest \
testsuites/diskqueue.conf \
arrayqueue.sh \
testsuites/arrayqueue.conf \
+ rscript_contains.sh \
+ testsuites/rscript_contains.conf \
linkedlistqueue.sh \
testsuites/linkedlistqueue.conf \
da-mainmsg-q.sh \
diff --git a/tests/rscript_contains.sh b/tests/rscript_contains.sh
new file mode 100755
index 00000000..fd5c3354
--- /dev/null
+++ b/tests/rscript_contains.sh
@@ -0,0 +1,13 @@
+# added 2012-09-14 by rgerhards
+# This file is part of the rsyslog project, released under ASL 2.0
+echo ===============================================================================
+echo \[rscript_contains.sh\]: test for contains script-filter
+source $srcdir/diag.sh init
+source $srcdir/diag.sh startup rscript_contains.conf
+source $srcdir/diag.sh injectmsg 0 5000
+echo doing shutdown
+source $srcdir/diag.sh shutdown-when-empty
+echo wait on shutdown
+source $srcdir/diag.sh wait-shutdown
+source $srcdir/diag.sh seq-check 0 4999
+source $srcdir/diag.sh exit
diff --git a/tests/testsuites/rscript_contains.conf b/tests/testsuites/rscript_contains.conf
new file mode 100644
index 00000000..8bead68a
--- /dev/null
+++ b/tests/testsuites/rscript_contains.conf
@@ -0,0 +1,4 @@
+$IncludeConfig diag-common.conf
+
+$template outfmt,"%msg:F,58:2%\n"
+if $msg contains 'msgnum' then ./rsyslog.out.log;outfmt