summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2013-10-14 12:26:41 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2013-10-14 12:26:41 +0100
commit17ce2968087dbd96e75fa4d7f3c2d9ca39bc0e4d (patch)
tree471d62ea2a4fe023fb01a1689723c426fa1d5d91 /src
parent5fb3f7dce739e8acd9b0da1bc815992957fe5877 (diff)
downloadrspamd-17ce2968087dbd96e75fa4d7f3c2d9ca39bc0e4d.tar.gz
rspamd-17ce2968087dbd96e75fa4d7f3c2d9ca39bc0e4d.zip
Fix leaks and errors in rcl_parser.
Diffstat (limited to 'src')
-rw-r--r--src/rcl/rcl_parser.c12
-rw-r--r--src/rcl/rcl_util.c2
2 files changed, 11 insertions, 3 deletions
diff --git a/src/rcl/rcl_parser.c b/src/rcl/rcl_parser.c
index e4a9024c7..d00b2d3eb 100644
--- a/src/rcl/rcl_parser.c
+++ b/src/rcl/rcl_parser.c
@@ -554,6 +554,12 @@ rspamd_cl_parse_key (struct rspamd_cl_parser *parser,
rspamd_cl_chunk_skipc (chunk, *p);
p ++;
}
+ else if (rspamd_cl_lex_is_comment (p[0], p[1])) {
+ if (!rspamd_cl_skip_comments (parser, err)) {
+ return FALSE;
+ }
+ p = chunk->pos;
+ }
else {
/* Invalid identifier */
rspamd_cl_set_err (chunk, RSPAMD_CL_ESYNTAX, "key must begin with a letter", err);
@@ -661,8 +667,8 @@ rspamd_cl_parse_key (struct rspamd_cl_parser *parser,
HASH_FIND_STR (container, nobj->key, tobj);
if (tobj != NULL) {
/* Just insert a new object as the next element */
- LL_PREPEND (tobj, nobj);
HASH_DELETE (hh, container, tobj);
+ LL_PREPEND (tobj, nobj);
}
HASH_ADD_KEYPTR (hh, container, nobj->key, strlen (nobj->key), nobj);
@@ -843,9 +849,9 @@ rspamd_cl_parse_value (struct rspamd_cl_parser *parser, struct rspamd_cl_chunk *
break;
default:
/* Skip any spaces and comments */
- if (rcl_test_character (*p, RCL_CHARACTER_WHITESPACE) ||
+ if (rcl_test_character (*p, RCL_CHARACTER_WHITESPACE_UNSAFE) ||
rspamd_cl_lex_is_comment (p[0], p[1])) {
- while (p < chunk->end && rcl_test_character (*p, RCL_CHARACTER_WHITESPACE)) {
+ while (p < chunk->end && rcl_test_character (*p, RCL_CHARACTER_WHITESPACE_UNSAFE)) {
rspamd_cl_chunk_skipc (chunk, *p);
p ++;
}
diff --git a/src/rcl/rcl_util.c b/src/rcl/rcl_util.c
index 8a42e40a4..a2cb444ea 100644
--- a/src/rcl/rcl_util.c
+++ b/src/rcl/rcl_util.c
@@ -197,6 +197,8 @@ rspamd_cl_parser_free (struct rspamd_cl_parser *parser)
g_slice_free1 (sizeof (struct rspamd_cl_stack), stack);
}
HASH_ITER (hh, parser->macroes, macro, mtmp) {
+ g_free (macro->name);
+ HASH_DEL (parser->macroes, macro);
g_slice_free1 (sizeof (struct rspamd_cl_macro), macro);
}
LL_FOREACH_SAFE (parser->chunks, chunk, ctmp) {