Skip to content

Commit 4a084d3

Browse files
committed
schema compile BUGFIX invalid identity exts parent pointers
Refs #2447
1 parent ccec3f4 commit 4a084d3

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/schema_compile.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ LY_ERR
177177
lys_identity_precompile(struct lysc_ctx *ctx_sc, struct ly_ctx *ctx, struct lysp_module *parsed_mod,
178178
const struct lysp_ident *identities_p, struct lysc_ident **identities)
179179
{
180-
LY_ARRAY_COUNT_TYPE u;
180+
LY_ARRAY_COUNT_TYPE u, v;
181181
struct lysc_ctx cctx = {0};
182182
struct lysc_ident *ident;
183183
LY_ERR ret = LY_SUCCESS;
@@ -216,6 +216,13 @@ lys_identity_precompile(struct lysc_ctx *ctx_sc, struct ly_ctx *ctx, struct lysp
216216
}
217217
lysc_update_path(ctx_sc, NULL, NULL);
218218

219+
/* revalidate the backward parent pointers from extensions now that the array is final */
220+
LY_ARRAY_FOR(*identities, u) {
221+
LY_ARRAY_FOR((*identities)[u].exts, v) {
222+
(*identities)[u].exts[v].parent = &(*identities)[u];
223+
}
224+
}
225+
219226
done:
220227
if (ret) {
221228
lysc_update_path(ctx_sc, NULL, NULL);

tests/utests/schema/test_schema.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2139,8 +2139,8 @@ test_compiled_print(void **state)
21392139
yang = "module m1 {yang-version 1.1; namespace urn:m1;prefix m1;"
21402140
"import ietf-yang-metadata {prefix md;}"
21412141
"extension a;"
2142-
"identity baseid;"
2143-
"identity id1 {base baseid;}"
2142+
"identity baseid {m1:a;}"
2143+
"identity id1 {base baseid; m1:a;}"
21442144
"feature feat;"
21452145
"container root {"
21462146
"leaf a {type instance-identifier;}"

0 commit comments

Comments
 (0)