Skip to content

Commit 6ea6fe2

Browse files
committed
diff MAINTENANCE non-null strdup arg
False-positive warning by Debian.
1 parent a1fc185 commit 6ea6fe2

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/diff.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,7 @@ lyd_diff_attrs(const struct lyd_node *first, const struct lyd_node *second, uint
459459
const char **orig_default, char **orig_value)
460460
{
461461
const struct lysc_node *schema;
462+
const char *str_val;
462463

463464
assert(first || second);
464465

@@ -526,7 +527,8 @@ lyd_diff_attrs(const struct lyd_node *first, const struct lyd_node *second, uint
526527
/* orig-value */
527528
if ((schema->nodetype & (LYS_LEAF | LYS_ANYDATA)) && (*op == LYD_DIFF_OP_REPLACE)) {
528529
if (schema->nodetype == LYS_LEAF) {
529-
*orig_value = strdup(lyd_get_value(first));
530+
str_val = lyd_get_value(first);
531+
*orig_value = strdup(str_val ? str_val : "");
530532
LY_CHECK_ERR_RET(!*orig_value, LOGMEM(schema->module->ctx), LY_EMEM);
531533
} else {
532534
LY_CHECK_RET(lyd_any_value_str(first, orig_value));

0 commit comments

Comments
 (0)