From 17ce2968087dbd96e75fa4d7f3c2d9ca39bc0e4d Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Mon, 14 Oct 2013 12:26:41 +0100 Subject: [PATCH] Fix leaks and errors in rcl_parser. --- src/rcl/rcl_parser.c | 12 +++++++++--- src/rcl/rcl_util.c | 2 ++ 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) { -- 2.39.5