Improve setjmp safety in config parser

This commit is contained in:
Přemysl Eric Janouch 2020-04-19 06:57:55 +02:00
parent bca7167d03
commit 317dfcb6e2
Signed by: p
GPG Key ID: A0420B94F92B9493

View File

@ -5254,7 +5254,9 @@ static struct config_item *
config_item_parse (const char *script, size_t len, config_item_parse (const char *script, size_t len,
bool single_value_only, struct error **e) 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; struct config_item *volatile object = NULL;
jmp_buf err; 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 // This is really only intended for in-program configuration
// and telling the line number would look awkward // and telling the line number would look awkward
parser.tokenizer.report_line = false; parser.tokenizer.report_line = false;
object = config_parser_parse_value (&parser, err); object = config_parser_parse_value (self, err);
} }
else else
object = config_parser_parse_object (&parser, err); object = config_parser_parse_object (self, err);
config_parser_expect (&parser, CONFIG_T_ABORT, err); config_parser_expect (self, CONFIG_T_ABORT, err);
end: end:
config_parser_free (&parser); config_parser_free (self);
return object; return object;
} }