commit b716e0f: [Minor] UCL: Avoid double free
Vsevolod Stakhov
vsevolod at highsecure.ru
Thu Dec 27 18:28:07 UTC 2018
Author: Vsevolod Stakhov
Date: 2018-12-13 14:06:13 +0000
URL: https://github.com/rspamd/rspamd/commit/b716e0fd650d5b9fc5985c6354460c5074bc5681
[Minor] UCL: Avoid double free
---
contrib/libucl/ucl_util.c | 16 +++++++---------
1 file 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);
More information about the Commits
mailing list