aboutsummaryrefslogtreecommitdiffstats
path: root/contrib
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-12-13 14:06:13 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2018-12-13 14:06:13 +0000
commitb716e0fd650d5b9fc5985c6354460c5074bc5681 (patch)
tree21c29ec851620eed15e44ae105500fa1c2a9f9bf /contrib
parente9cf00459aa1e4d6501c0c0da7ab488f6d4be801 (diff)
downloadrspamd-b716e0fd650d5b9fc5985c6354460c5074bc5681.tar.gz
rspamd-b716e0fd650d5b9fc5985c6354460c5074bc5681.zip
[Minor] UCL: Avoid double free
Diffstat (limited to 'contrib')
-rw-r--r--contrib/libucl/ucl_util.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/contrib/libucl/ucl_util.c b/contrib/libucl/ucl_util.c
index fb185e48b..051ac2c27 100644
--- a/contrib/libucl/ucl_util.c
+++ b/contrib/libucl/ucl_util.c
@@ -1149,6 +1149,7 @@ ucl_include_file_single (const unsigned char *data, size_t len,
}
old_curfile = parser->cur_file;
+ parser->cur_file = NULL;
/* Store old file vars */
DL_FOREACH_SAFE (parser->variables, cur_var, tmp_var) {
@@ -1929,15 +1930,16 @@ ucl_parser_set_filevars (struct ucl_parser *parser, const char *filename, bool n
ucl_strlcpy (realbuf, filename, sizeof (realbuf));
}
+ if (parser->cur_file) {
+ free (parser->cur_file);
+ }
+
+ parser->cur_file = strdup (realbuf);
+
/* Define variables */
ucl_parser_register_variable (parser, "FILENAME", realbuf);
curdir = dirname (realbuf);
ucl_parser_register_variable (parser, "CURDIR", curdir);
-
- if (parser->cur_file) {
- free (parser->cur_file);
- }
- parser->cur_file = strdup (filename);
}
else {
/* Set everything from the current dir */
@@ -1970,10 +1972,6 @@ ucl_parser_add_file_full (struct ucl_parser *parser, const char *filename,
return false;
}
- if (parser->cur_file) {
- free (parser->cur_file);
- }
- parser->cur_file = strdup (realbuf);
ucl_parser_set_filevars (parser, realbuf, false);
ret = ucl_parser_add_chunk_full (parser, buf, len, priority, strat,
parse_type);