diff --git a/src/ly_common.c b/src/ly_common.c index 449c862f9..ac62677ef 100644 --- a/src/ly_common.c +++ b/src/ly_common.c @@ -325,6 +325,7 @@ ly_utf8_and_equal(const char *input, int bytes, ...) /* compare each byte */ if (((uint8_t)input[i] & and) != (uint8_t)byte) { + va_end(ap); return 0; } } @@ -355,8 +356,10 @@ ly_utf8_less(const char *input, int bytes, ...) /* compare until bytes differ */ if ((uint8_t)input[i] > (uint8_t)byte) { + va_end(ap); return 0; } else if ((uint8_t)input[i] < (uint8_t)byte) { + va_end(ap); return 1; } } @@ -388,8 +391,10 @@ ly_utf8_greater(const char *input, int bytes, ...) /* compare until bytes differ */ if ((uint8_t)input[i] > (uint8_t)byte) { + va_end(ap); return 1; } else if ((uint8_t)input[i] < (uint8_t)byte) { + va_end(ap); return 0; } } diff --git a/src/parser_lyb.c b/src/parser_lyb.c index 1622b5d99..453cab365 100644 --- a/src/parser_lyb.c +++ b/src/parser_lyb.c @@ -837,7 +837,7 @@ lyb_parse_schema_hash(struct lyd_lyb_ctx *lybctx, const struct lysc_node *sparen } else if (mod) { LOGVAL(lybctx->lybctx->ctx, LYVE_REFERENCE, "Failed to find matching hash for a top-level node" " from \"%s\".", mod->name); - } else { + } else if (sparent) { LOGVAL(lybctx->lybctx->ctx, LYVE_REFERENCE, "Failed to find matching hash for a child node" " of \"%s\".", sparent->name); } diff --git a/src/parser_yin.c b/src/parser_yin.c index a280423d8..fb10e1784 100644 --- a/src/parser_yin.c +++ b/src/parser_yin.c @@ -396,6 +396,7 @@ subelems_allocator(struct lysp_yin_ctx *ctx, size_t count, struct lysp_node *par return LY_SUCCESS; mem_err: + va_end(ap); subelems_deallocator(count, *result); LOGMEM(ctx->xmlctx->ctx); return LY_EMEM; diff --git a/src/schema_compile_node.c b/src/schema_compile_node.c index 9c230cd73..b54a8f9a4 100644 --- a/src/schema_compile_node.c +++ b/src/schema_compile_node.c @@ -1229,7 +1229,9 @@ lys_compile_pattern_chblocks_xmlschema2perl(const struct ly_ctx *ctx, const char ++idx; } if ((perl_regex[idx2] == ']') && (!idx2 || (perl_regex[idx2 - 1] != '\\'))) { - --idx; + if (idx > 0) { + --idx; + } } } if (idx) { @@ -1699,7 +1701,8 @@ static LY_ERR lys_new_type(const struct ly_ctx *ctx, LY_DATA_TYPE basetype, const char *tpdf_name, struct lysc_type **type) { LY_ERR rc = LY_SUCCESS; - struct lysc_type *t = NULL; + void *t = NULL; + struct lysc_type *t2 = NULL; *type = NULL; @@ -1749,9 +1752,11 @@ lys_new_type(const struct ly_ctx *ctx, LY_DATA_TYPE basetype, const char *tpdf_n break; } LY_CHECK_ERR_GOTO(!t, LOGMEM(ctx); rc = LY_EMEM, cleanup); + /* memory is available then set to used pointer */ + t2 = (struct lysc_type *)t; if (tpdf_name) { - rc = lydict_insert(ctx, tpdf_name, 0, &t->name); + rc = lydict_insert(ctx, tpdf_name, 0, &t2->name); LY_CHECK_GOTO(rc, cleanup); } @@ -1759,7 +1764,7 @@ lys_new_type(const struct ly_ctx *ctx, LY_DATA_TYPE basetype, const char *tpdf_n if (rc) { free(t); } else { - *type = t; + *type = t2; } return rc; } diff --git a/src/xpath.c b/src/xpath.c index 5429eca74..7fb3c9260 100644 --- a/src/xpath.c +++ b/src/xpath.c @@ -8250,7 +8250,9 @@ eval_name_test_with_predicate(const struct lyxp_expr *exp, uint32_t *tok_idx, en if (set->used) { i = set->used; do { - --i; + if (i > 0) { + --i; + } if (set->val.scnodes[i].in_ctx > LYXP_SET_SCNODE_ATOM_NODE) { found = 1; break;