Skip to content

Commit

Permalink
Fix load macro with try=true
Browse files Browse the repository at this point in the history
  • Loading branch information
vstakhov committed Jan 8, 2023
1 parent 250938e commit 5fd0de9
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/ucl_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -1022,6 +1022,9 @@ ucl_include_url (const unsigned char *data, size_t len,
snprintf (urlbuf, sizeof (urlbuf), "%.*s", (int)len, data);

if (!ucl_fetch_url (urlbuf, &buf, &buflen, &parser->err, params->must_exist)) {
if (!params->must_exist) {
ucl_parser_clear_error (parser);
}
return !params->must_exist;
}

Expand Down Expand Up @@ -1133,6 +1136,8 @@ ucl_include_file_single (const unsigned char *data, size_t len,
return false;
}

ucl_parser_clear_error (parser);

return true;
}

Expand Down Expand Up @@ -1852,6 +1857,10 @@ ucl_load_handler (const unsigned char *data, size_t len,
!try_load)) {
free (load_file);

if (try_load) {
ucl_parser_clear_error (parser);
}

return (try_load || false);
}

Expand Down Expand Up @@ -3951,4 +3960,4 @@ const char *
ucl_parser_get_cur_file (struct ucl_parser *parser)
{
return parser->cur_file;
}
}

0 comments on commit 5fd0de9

Please sign in to comment.