Skip to content

Commit 9a91bd7

Browse files
committed
schema compile BUGFIX invalid enum ext parent pointer
Fixes #2447
1 parent 4fdf94e commit 9a91bd7

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

src/printer_context.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -982,6 +982,7 @@ ctxp_children(const struct lysc_node *orig_child, struct lysc_node **child, stru
982982
ch = *mem;
983983
*mem = (char *)*mem + CTXP_MEM_SIZE(node_size);
984984

985+
/* referenced by pointers */
985986
ly_ctx_compiled_addr_ht_add(addr_ht, orig_child, ch);
986987
ctxp_node(orig_child, ch, addr_ht, ptr_set, mem);
987988

src/schema_compile_node.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1623,6 +1623,13 @@ lys_compile_type_enums(struct lysc_ctx *ctx, const struct lysp_type_enum *enums_
16231623
}
16241624
}
16251625

1626+
/* revalidate the backward parent pointers from extensions now that the array is final */
1627+
LY_ARRAY_FOR(*bitenums, u) {
1628+
LY_ARRAY_FOR((*bitenums)[u].exts, v) {
1629+
(*bitenums)[u].exts[v].parent = &(*bitenums)[u];
1630+
}
1631+
}
1632+
16261633
done:
16271634
return ret;
16281635
}

tests/utests/schema/test_schema.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2157,7 +2157,7 @@ test_compiled_print(void **state)
21572157
" leaf b {type string;}"
21582158
" leaf c {type uint32;}"
21592159
" leaf d {type empty;}"
2160-
" leaf e {type int8;}"
2160+
" leaf e {type enumeration {enum one {m1:a;} enum two;}}"
21612161
"}"
21622162
"}"
21632163
"rpc h {"
@@ -2240,7 +2240,7 @@ test_compiled_print(void **state)
22402240
" <b>unique</b>\n"
22412241
" <c>123</c>\n"
22422242
" <d/>\n"
2243-
" <e>-10</e>\n"
2243+
" <e>two</e>\n"
22442244
" </g>\n"
22452245
" <a xmlns=\"urn:m2\" xmlns:m1=\"urn:m1\">m1:id1</a>\n"
22462246
"</root>\n";

0 commit comments

Comments
 (0)