Skip to content

Commit 45ecf55

Browse files
committed
schema parsing BUGFIX infinite loop when duplicating unresolved identityref
1 parent 693ffb5 commit 45ecf55

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/resolve.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6676,7 +6676,7 @@ unres_schema_find(struct unres_schema *unres, int start_on_backwards, void *item
66766676
int i;
66776677
struct unres_list_uniq *aux_uniq1, *aux_uniq2;
66786678

6679-
if (start_on_backwards > 0) {
6679+
if (start_on_backwards >= 0) {
66806680
i = start_on_backwards;
66816681
} else {
66826682
i = unres->count - 1;

src/tree_schema.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,12 +1169,15 @@ type_dup(struct lys_module *mod, struct lys_node *parent, struct lys_type *new,
11691169
} else {
11701170
/* there can be several unresolved base identities, duplicate them all */
11711171
i = -1;
1172-
while ((i = unres_schema_find(unres, i, old, UNRES_TYPE_IDENTREF)) != -1) {
1173-
if (unres_schema_add_str(mod, unres, new, UNRES_TYPE_IDENTREF, unres->str_snode[i]) == -1) {
1174-
return -1;
1172+
do {
1173+
i = unres_schema_find(unres, i, old, UNRES_TYPE_IDENTREF);
1174+
if (i != -1) {
1175+
if (unres_schema_add_str(mod, unres, new, UNRES_TYPE_IDENTREF, unres->str_snode[i]) == -1) {
1176+
return -1;
1177+
}
11751178
}
11761179
--i;
1177-
}
1180+
} while (i > -1);
11781181
}
11791182
break;
11801183

0 commit comments

Comments
 (0)