Skip to content

Coverity_fixes_jsc-se #2387

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/ly_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/parser_lyb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
1 change: 1 addition & 0 deletions src/parser_yin.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
13 changes: 9 additions & 4 deletions src/schema_compile_node.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -1749,17 +1752,19 @@ 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);
}

cleanup:
if (rc) {
free(t);
} else {
*type = t;
*type = t2;
}
return rc;
}
Expand Down
4 changes: 3 additions & 1 deletion src/xpath.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down