aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libucl/ucl_parser.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/libucl/ucl_parser.c')
-rw-r--r--contrib/libucl/ucl_parser.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/contrib/libucl/ucl_parser.c b/contrib/libucl/ucl_parser.c
index ac3fe0543..7a935a5c7 100644
--- a/contrib/libucl/ucl_parser.c
+++ b/contrib/libucl/ucl_parser.c
@@ -2298,7 +2298,7 @@ ucl_state_machine (struct ucl_parser *parser)
ucl_chunk_skipc (chunk, p);
}
else {
- if (p - c > 0) {
+ if (c != NULL && p - c > 0) {
/* We got macro name */
macro_len = (size_t) (p - c);
HASH_FIND (hh, parser->macroes, c, macro_len, macro);
@@ -2351,7 +2351,7 @@ ucl_state_machine (struct ucl_parser *parser)
macro_start, macro_len);
parser->state = parser->prev_state;
- if (macro_escaped == NULL) {
+ if (macro_escaped == NULL && macro != NULL) {
if (macro->is_context) {
ret = macro->h.context_handler (macro_start, macro_len,
macro_args,
@@ -2363,7 +2363,7 @@ ucl_state_machine (struct ucl_parser *parser)
macro->ud);
}
}
- else {
+ else if (macro != NULL) {
if (macro->is_context) {
ret = macro->h.context_handler (macro_escaped, macro_len,
macro_args,
@@ -2377,15 +2377,22 @@ ucl_state_machine (struct ucl_parser *parser)
UCL_FREE (macro_len + 1, macro_escaped);
}
+ else {
+ ret = false;
+ ucl_set_err (parser, UCL_EINTERNAL,
+ "internal error: parser has macro undefined", &parser->err);
+ }
/*
* Chunk can be modified within macro handler
*/
chunk = parser->chunks;
p = chunk->pos;
+
if (macro_args) {
ucl_object_unref (macro_args);
}
+
if (!ret) {
return false;
}