From ff83de0104b73b4ac8350ad056c6c853cfd0cff4 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Thu, 30 May 2019 17:23:44 +0100 Subject: [PATCH] [Minor] LibUCL: Fix reading at the end of chunk --- contrib/libucl/ucl_parser.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/contrib/libucl/ucl_parser.c b/contrib/libucl/ucl_parser.c index 7313b28a3..b048f426a 100644 --- a/contrib/libucl/ucl_parser.c +++ b/contrib/libucl/ucl_parser.c @@ -2366,20 +2366,22 @@ ucl_state_machine (struct ucl_parser *parser) p = chunk->pos; - if (*p == '[') { - parser->state = UCL_STATE_VALUE; - ucl_chunk_skipc (chunk, p); - seen_obrace = true; - } - else { - - if (*p == '{') { + if (p < chunk->end) { + if (*p == '[') { + parser->state = UCL_STATE_VALUE; ucl_chunk_skipc (chunk, p); - parser->state = UCL_STATE_KEY_OBRACE; seen_obrace = true; } else { - parser->state = UCL_STATE_KEY; + + if (*p == '{') { + ucl_chunk_skipc (chunk, p); + parser->state = UCL_STATE_KEY_OBRACE; + seen_obrace = true; + } + else { + parser->state = UCL_STATE_KEY; + } } } -- 2.39.5