Skip to content

Commit 79fb578

Browse files
authored
libyang BUGFIX minor bug fixes found by coverity (#2386)
* src/plugins_types/union.c: coverity fix - overflowed integer argument * src/tree_data_common.c: coveritx fix - out-of-bounds access * src/tree_edit.h: coverity fix - out-of-bounds access * src/tree_schema.c: coverity fix - resource leak
1 parent 682d7ff commit 79fb578

File tree

4 files changed

+5
-1
lines changed

4 files changed

+5
-1
lines changed

src/plugins_types/union.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,8 @@ union_find_type(const struct ly_ctx *ctx, struct lysc_type_union *type_u, struct
350350
}
351351
if (msg_len == -1) {
352352
LY_CHECK_ERR_GOTO(!errs, ret = LY_EMEM, cleanup);
353+
/* for further actions in function msg_len is just 0 */
354+
msg_len = 0;
353355
}
354356
for (u = 0; u < LY_ARRAY_COUNT(type_u->types); ++u) {
355357
if (!errs[u]) {

src/tree_data_common.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,7 @@ lyd_value_store(const struct ly_ctx *ctx, struct lyd_value *val, const struct ly
516516

517517
if (!value) {
518518
value = "";
519+
value_len = 0;
519520
}
520521
if (incomplete) {
521522
*incomplete = 0;

src/tree_edit.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ void *ly_realloc(void *ptr, size_t size);
148148
} \
149149
p__ = (char *)((LY_ARRAY_COUNT_TYPE*)(p__) + 1); \
150150
memcpy(&(ARRAY), &p__, sizeof p__); \
151-
if (ARRAY) { \
151+
if ((ARRAY) && (SIZE > 0)) { \
152152
memset(&(ARRAY)[*((LY_ARRAY_COUNT_TYPE*)(p__) - 1)], 0, (SIZE) * sizeof *(ARRAY)); \
153153
} \
154154
}

src/tree_schema.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -788,6 +788,7 @@ lysc_path_until(const struct lysc_node *node, const struct lysc_node *parent, LY
788788
if (buffer) {
789789
strcpy(buffer, "/");
790790
} else {
791+
free(path);
791792
path = strdup("/");
792793
}
793794
}

0 commit comments

Comments
 (0)