summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2017-06-11 13:18:52 (GMT)
committer Daniel Silverstone <dsilvers@digital-scurf.org>2017-06-11 13:18:52 (GMT)
commit87a3522b47394d611e4eb7bb1ba360cff6a939dc (patch)
treeeaf2fa1b802be8d9558d1807d9d5a0559995eed5
parentbb14663d67406101a5a4b5afbf9588d813f12656 (diff)
downloadlibnslog-87a3522b47394d611e4eb7bb1ba360cff6a939dc.tar.gz
libnslog-87a3522b47394d611e4eb7bb1ba360cff6a939dc.tar.bz2
Fix up some parser snafu for release mode
-rw-r--r--Makefile2
-rw-r--r--src/filter-parser.y49
-rw-r--r--test/basictests.c4
3 files changed, 43 insertions, 12 deletions
diff --git a/Makefile b/Makefile
index 26cf49f..5c9c7b8 100644
--- a/Makefile
+++ b/Makefile
@@ -32,7 +32,7 @@ else
# __inline__ is a GCCism
CFLAGS := $(CFLAGS) -Dinline="__inline__"
endif
-CFLAGS := $(CFLAGS) -D_POSIX_C_SOURCE=200809L
+CFLAGS := $(CFLAGS) -D_POSIX_C_SOURCE=200809L -g
REQUIRED_LIBS := nslog
diff --git a/src/filter-parser.y b/src/filter-parser.y
index bb225b6..2ccb3c8 100644
--- a/src/filter-parser.y
+++ b/src/filter-parser.y
@@ -33,6 +33,10 @@ static void filter_error(FILTER_LTYPE *loc, nslog_filter_t **output, const char
nslog_filter_t *filter;
}
+%destructor {
+ nslog_filter_unref($$);
+} <filter>
+
%token <patt> T_PATTERN
%token <level> T_LEVEL
@@ -88,35 +92,45 @@ expression ::= term | '!' term
level_filter:
T_LEVEL_SPECIFIER T_LEVEL
{
- assert(nslog_filter_level_new($2, &$$) == NSLOG_NO_ERROR);
+ if (nslog_filter_level_new($2, &$$) != NSLOG_NO_ERROR) {
+ YYABORT ;
+ }
}
;
category_filter:
T_CATEGORY_SPECIFIER T_PATTERN
{
- assert(nslog_filter_category_new($2, &$$) == NSLOG_NO_ERROR);
+ if (nslog_filter_category_new($2, &$$) != NSLOG_NO_ERROR) {
+ YYABORT ;
+ }
}
;
filename_filter:
T_FILENAME_SPECIFIER T_PATTERN
{
- assert(nslog_filter_filename_new($2, &$$) == NSLOG_NO_ERROR);
+ if (nslog_filter_filename_new($2, &$$) != NSLOG_NO_ERROR) {
+ YYABORT ;
+ }
}
;
dirname_filter:
T_DIRNAME_SPECIFIER T_PATTERN
{
- assert(nslog_filter_dirname_new($2, &$$) == NSLOG_NO_ERROR);
+ if (nslog_filter_dirname_new($2, &$$) != NSLOG_NO_ERROR) {
+ YYABORT ;
+ }
}
;
funcname_filter:
T_FUNCNAME_SPECIFIER T_PATTERN
{
- assert(nslog_filter_funcname_new($2, &$$) == NSLOG_NO_ERROR);
+ if (nslog_filter_funcname_new($2, &$$) != NSLOG_NO_ERROR) {
+ YYABORT ;
+ }
}
;
@@ -135,7 +149,11 @@ basic_filter:
and_filter:
'(' filter T_OP_AND filter ')'
{
- assert(nslog_filter_and_new($2, $4, &$$) == NSLOG_NO_ERROR);
+ if (nslog_filter_and_new($2, $4, &$$) != NSLOG_NO_ERROR) {
+ nslog_filter_unref($2);
+ nslog_filter_unref($4);
+ YYABORT ;
+ }
nslog_filter_unref($2);
nslog_filter_unref($4);
}
@@ -144,7 +162,11 @@ and_filter:
or_filter:
'(' filter T_OP_OR filter ')'
{
- assert(nslog_filter_or_new($2, $4, &$$) == NSLOG_NO_ERROR);
+ if (nslog_filter_or_new($2, $4, &$$) != NSLOG_NO_ERROR) {
+ nslog_filter_unref($2);
+ nslog_filter_unref($4);
+ YYABORT ;
+ }
nslog_filter_unref($2);
nslog_filter_unref($4);
}
@@ -153,7 +175,11 @@ or_filter:
xor_filter:
'(' filter '^' filter ')'
{
- assert(nslog_filter_xor_new($2, $4, &$$) == NSLOG_NO_ERROR);
+ if (nslog_filter_xor_new($2, $4, &$$) != NSLOG_NO_ERROR) {
+ nslog_filter_unref($2);
+ nslog_filter_unref($4);
+ YYABORT ;
+ }
nslog_filter_unref($2);
nslog_filter_unref($4);
}
@@ -170,7 +196,10 @@ binary_filter:
not_filter:
'!' filter
{
- assert(nslog_filter_not_new($2, &$$) == NSLOG_NO_ERROR);
+ if (nslog_filter_not_new($2, &$$) != NSLOG_NO_ERROR) {
+ nslog_filter_unref($2);
+ YYABORT ;
+ }
nslog_filter_unref($2);
}
;
@@ -186,7 +215,7 @@ filter:
toplevel:
filter
{
- $$ = *output = $1;
+ $$ = *output = nslog_filter_ref($1);
}
|
error
diff --git a/test/basictests.c b/test/basictests.c
index a9b8ab0..b03bd7b 100644
--- a/test/basictests.c
+++ b/test/basictests.c
@@ -279,9 +279,11 @@ END_TEST
START_TEST (test_nslog_parse_and_sprintf)
{
- nslog_filter_t *filt;
+ nslog_filter_t *filt = NULL;
fail_unless(nslog_filter_from_text("cat:test", &filt) == NSLOG_NO_ERROR,
"Unable to parse cat:test");
+ fail_unless(filt != NULL,
+ "Strange, despite parsing okay, filt was NULL");
char *ct = nslog_filter_sprintf(filt);
nslog_filter_unref(filt);
fail_unless(strcmp(ct, "cat:test") == 0,