Skip to content

Commit b64958d

Browse files
committed
src/schema_compile_node.c: coverity fix - wrong sizeof argument
1 parent aad24f5 commit b64958d

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/schema_compile_node.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1701,7 +1701,8 @@ static LY_ERR
17011701
lys_new_type(const struct ly_ctx *ctx, LY_DATA_TYPE basetype, const char *tpdf_name, struct lysc_type **type)
17021702
{
17031703
LY_ERR rc = LY_SUCCESS;
1704-
struct lysc_type *t = NULL;
1704+
void *t = NULL;
1705+
struct lysc_type *t2 = NULL;
17051706

17061707
*type = NULL;
17071708

@@ -1751,17 +1752,19 @@ lys_new_type(const struct ly_ctx *ctx, LY_DATA_TYPE basetype, const char *tpdf_n
17511752
break;
17521753
}
17531754
LY_CHECK_ERR_GOTO(!t, LOGMEM(ctx); rc = LY_EMEM, cleanup);
1755+
/* memory is available then set to used pointer */
1756+
t2 = (struct lysc_type *)t;
17541757

17551758
if (tpdf_name) {
1756-
rc = lydict_insert(ctx, tpdf_name, 0, &t->name);
1759+
rc = lydict_insert(ctx, tpdf_name, 0, &t2->name);
17571760
LY_CHECK_GOTO(rc, cleanup);
17581761
}
17591762

17601763
cleanup:
17611764
if (rc) {
17621765
free(t);
17631766
} else {
1764-
*type = t;
1767+
*type = t2;
17651768
}
17661769
return rc;
17671770
}

0 commit comments

Comments
 (0)