Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue with incorrect state handling #295

Merged
merged 1 commit into from
Apr 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/ucl_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -1821,6 +1821,9 @@ ucl_parse_value (struct ucl_parser *parser, struct ucl_chunk *chunk)
case '{':
obj = ucl_parser_get_container (parser);
if (obj == NULL) {
parser->state = UCL_STATE_ERROR;
ucl_set_err(parser, UCL_ESYNTAX, "object value must be a part of an object",
&parser->err);
return false;
}
/* We have a new object */
Expand All @@ -1842,6 +1845,9 @@ ucl_parse_value (struct ucl_parser *parser, struct ucl_chunk *chunk)
case '[':
obj = ucl_parser_get_container (parser);
if (obj == NULL) {
parser->state = UCL_STATE_ERROR;
ucl_set_err(parser, UCL_ESYNTAX, "array value must be a part of an object",
&parser->err);
return false;
}
/* We have a new array */
Expand Down Expand Up @@ -1873,6 +1879,12 @@ ucl_parse_value (struct ucl_parser *parser, struct ucl_chunk *chunk)
break;
case '<':
obj = ucl_parser_get_container (parser);
if (obj == NULL) {
parser->state = UCL_STATE_ERROR;
ucl_set_err(parser, UCL_ESYNTAX, "multiline value must be a part of an object",
&parser->err);
return false;
}
/* We have something like multiline value, which must be <<[A-Z]+\n */
if (chunk->end - p > 3) {
if (memcmp (p, "<<", 2) == 0) {
Expand Down Expand Up @@ -1924,6 +1936,13 @@ ucl_parse_value (struct ucl_parser *parser, struct ucl_chunk *chunk)
obj = ucl_parser_get_container (parser);
}

if (obj == NULL) {
parser->state = UCL_STATE_ERROR;
ucl_set_err(parser, UCL_ESYNTAX, "value must be a part of an object",
&parser->err);
return false;
}

/* Parse atom */
if (ucl_test_character (*p, UCL_CHARACTER_VALUE_DIGIT_START)) {
if (!ucl_lex_number (parser, chunk, obj)) {
Expand Down
Loading