aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p@janouch.name>2020-04-19 06:57:55 +0200
committerPřemysl Janouch <p@janouch.name>2020-04-19 07:02:13 +0200
commit317dfcb6e2abffd2c2d1a0c206238ac16e0aced1 (patch)
tree09e4293f475479acd305107b089b8316818e6037
parentbca7167d037d857448cb18243425d7c61de3bdd5 (diff)
downloadliberty-317dfcb6e2abffd2c2d1a0c206238ac16e0aced1.tar.gz
liberty-317dfcb6e2abffd2c2d1a0c206238ac16e0aced1.tar.xz
liberty-317dfcb6e2abffd2c2d1a0c206238ac16e0aced1.zip
Improve setjmp safety in config parser
-rw-r--r--liberty.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/liberty.c b/liberty.c
index eadace3..92974cc 100644
--- a/liberty.c
+++ b/liberty.c
@@ -5254,7 +5254,9 @@ static struct config_item *
config_item_parse (const char *script, size_t len,
bool single_value_only, struct error **e)
{
- struct config_parser parser = config_parser_make (script, len);
+ volatile struct config_parser parser = config_parser_make (script, len);
+ struct config_parser *volatile self = (struct config_parser *) &parser;
+
struct config_item *volatile object = NULL;
jmp_buf err;
@@ -5276,13 +5278,13 @@ config_item_parse (const char *script, size_t len,
// This is really only intended for in-program configuration
// and telling the line number would look awkward
parser.tokenizer.report_line = false;
- object = config_parser_parse_value (&parser, err);
+ object = config_parser_parse_value (self, err);
}
else
- object = config_parser_parse_object (&parser, err);
- config_parser_expect (&parser, CONFIG_T_ABORT, err);
+ object = config_parser_parse_object (self, err);
+ config_parser_expect (self, CONFIG_T_ABORT, err);
end:
- config_parser_free (&parser);
+ config_parser_free (self);
return object;
}