From ea69339bddad35b63d17ef350a41b3db3341230e Mon Sep 17 00:00:00 2001 From: Eugene K Date: Fri, 26 Feb 2021 16:50:22 -0500 Subject: [PATCH] avoid crash on parse error --- library/model_support.c | 10 +++++----- library/ziti.c | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/library/model_support.c b/library/model_support.c index a3038334..a5596641 100644 --- a/library/model_support.c +++ b/library/model_support.c @@ -67,12 +67,12 @@ jsmntok_t* parse_tokens(jsmn_parser *parser, const char *json, size_t len, size_ *ntok = 0; } else { *ntok = rc; - } - if (*ntok == tok_cap) { - toks = realloc(toks, (tok_cap + 1) * sizeof(jsmntok_t)); - } - toks[*ntok].type = JSMN_UNDEFINED; + if (*ntok == tok_cap) { + toks = realloc(toks, (tok_cap + 1) * sizeof(jsmntok_t)); + } + toks[*ntok].type = JSMN_UNDEFINED; + } return toks; } diff --git a/library/ziti.c b/library/ziti.c index c6064a65..939bd41a 100644 --- a/library/ziti.c +++ b/library/ziti.c @@ -163,7 +163,7 @@ int ziti_init_opts(ziti_options *options, uv_loop_t *loop) { ziti_log_init(loop, ZITI_LOG_DEFAULT_LEVEL, NULL); metrics_init(loop, 5); - PREP(ziti); + PREPF(ziti, ziti_errorstr); if (options->config == NULL && (options->controller == NULL || options->tls == NULL)) { ZITI_LOG(ERROR, "config or controller/tls has to be set");