Skip to content

Commit 3916aa9

Browse files
committed
BUGFIX NULL variable dereference
1 parent 9959f3e commit 3916aa9

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

src/parser.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1718,7 +1718,7 @@ lyp_parse_value(struct lys_type *type, const char **value_, struct lyxml_elem *x
17181718
tpdf = tpdf->type.der);
17191719
if (tpdf->module && xml) {
17201720
/* convert value into the json format */
1721-
value = transform_xml2json(ctx, value, xml, 1, 1);
1721+
value = transform_xml2json(ctx, value ? value : "", xml, 1, 1);
17221722
if (!value) {
17231723
/* invalid instance-identifier format */
17241724
if (leaf) {

src/tree_data.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5811,8 +5811,10 @@ lyd_dup_withsiblings_r(const struct lyd_node *first, struct lyd_node *parent_dup
58115811

58125812
error:
58135813
/* disconnect and free */
5814-
first_dup->parent = NULL;
5815-
lyd_free_withsiblings(first_dup);
5814+
if (first_dup) {
5815+
first_dup->parent = NULL;
5816+
lyd_free_withsiblings(first_dup);
5817+
}
58165818
return NULL;
58175819
}
58185820

src/xpath.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6808,7 +6808,7 @@ moveto_op_math(struct lyxp_set *set1, struct lyxp_set *set2, const char *op, str
68086808
break;
68096809

68106810
default:
6811-
LOGINT(local_mod->ctx);
6811+
LOGINT(local_mod ? local_mod->ctx : NULL);
68126812
return -1;
68136813
}
68146814

@@ -6962,7 +6962,7 @@ eval_node_test(struct lyxp_expr *exp, uint16_t *exp_idx, struct lyd_node *cur_no
69626962
break;
69636963

69646964
default:
6965-
LOGINT(local_mod->ctx);
6965+
LOGINT(local_mod ? local_mod->ctx : NULL);
69666966
return -1;
69676967
}
69686968

@@ -7239,7 +7239,7 @@ eval_relative_location_path(struct lyxp_expr *exp, uint16_t *exp_idx, struct lyd
72397239
break;
72407240

72417241
default:
7242-
LOGINT(local_mod->ctx);
7242+
LOGINT(local_mod ? local_mod->ctx : NULL);
72437243
return -1;
72447244
}
72457245
} while ((exp->used > *exp_idx) && (exp->tokens[*exp_idx] == LYXP_TOKEN_OPERATOR_PATH));
@@ -8661,7 +8661,7 @@ lyxp_set_cast(struct lyxp_set *set, enum lyxp_set_type target, const struct lyd_
86618661
LY_CHECK_ERR_RETURN(!set->val.str, LOGMEM(local_mod->ctx), -1);
86628662
break;
86638663
default:
8664-
LOGINT(local_mod->ctx);
8664+
LOGINT(local_mod ? local_mod->ctx : NULL);
86658665
return -1;
86668666
}
86678667
set->type = LYXP_SET_STRING;
@@ -8683,7 +8683,7 @@ lyxp_set_cast(struct lyxp_set *set, enum lyxp_set_type target, const struct lyd_
86838683
}
86848684
break;
86858685
default:
8686-
LOGINT(local_mod->ctx);
8686+
LOGINT(local_mod ? local_mod->ctx : NULL);
86878687
return -1;
86888688
}
86898689
set->type = LYXP_SET_NUMBER;
@@ -8718,7 +8718,7 @@ lyxp_set_cast(struct lyxp_set *set, enum lyxp_set_type target, const struct lyd_
87188718
set->val.bool = 0;
87198719
break;
87208720
default:
8721-
LOGINT(local_mod->ctx);
8721+
LOGINT(local_mod ? local_mod->ctx : NULL);
87228722
return -1;
87238723
}
87248724
set->type = LYXP_SET_BOOLEAN;

0 commit comments

Comments
 (0)