schema parsing BUGFIX infinite loop when duplicating unresolved identityref
diff --git a/src/resolve.c b/src/resolve.c
index def7039..67b6707 100644
--- a/src/resolve.c
+++ b/src/resolve.c
@@ -6647,7 +6647,7 @@
int i;
struct unres_list_uniq *aux_uniq1, *aux_uniq2;
- if (start_on_backwards > 0) {
+ if (start_on_backwards >= 0) {
i = start_on_backwards;
} else {
i = unres->count - 1;
diff --git a/src/tree_schema.c b/src/tree_schema.c
index eb6481a..2d9ab3e 100644
--- a/src/tree_schema.c
+++ b/src/tree_schema.c
@@ -1175,12 +1175,15 @@
} else {
/* there can be several unresolved base identities, duplicate them all */
i = -1;
- while ((i = unres_schema_find(unres, i, old, UNRES_TYPE_IDENTREF)) != -1) {
- if (unres_schema_add_str(mod, unres, new, UNRES_TYPE_IDENTREF, unres->str_snode[i]) == -1) {
- return -1;
+ do {
+ i = unres_schema_find(unres, i, old, UNRES_TYPE_IDENTREF);
+ if (i != -1) {
+ if (unres_schema_add_str(mod, unres, new, UNRES_TYPE_IDENTREF, unres->str_snode[i]) == -1) {
+ return -1;
+ }
}
--i;
- }
+ } while (i > -1);
}
break;