@@ -1208,6 +1208,49 @@ lys_compile_unres_depset_implement(struct ly_ctx *ctx, struct lys_glob_unres *un
1208
1208
return LY_SUCCESS ;
1209
1209
}
1210
1210
1211
+ /**
1212
+ * @brief Check that a disabled node (to be freed) can be freed and is not referenced.
1213
+ *
1214
+ * @param[in] node Disabled node to check.
1215
+ * @return LY_ERR value.
1216
+ */
1217
+ static LY_ERR
1218
+ lys_compile_unres_check_disabled (const struct lysc_node * node )
1219
+ {
1220
+ const struct lysc_node * parent ;
1221
+ const struct lysc_node_list * slist ;
1222
+ LY_ARRAY_COUNT_TYPE u , v ;
1223
+
1224
+ if (node -> flags & LYS_KEY ) {
1225
+ LOG_LOCSET (node , NULL );
1226
+ LOGVAL (node -> module -> ctx , LYVE_REFERENCE , "Key \"%s\" is disabled." , node -> name );
1227
+ LOG_LOCBACK (1 , 0 );
1228
+ return LY_EVALID ;
1229
+ }
1230
+
1231
+ for (parent = node -> parent ; parent ; parent = parent -> parent ) {
1232
+ if (parent -> nodetype != LYS_LIST ) {
1233
+ continue ;
1234
+ }
1235
+
1236
+ /* check list uniques */
1237
+ slist = (struct lysc_node_list * )parent ;
1238
+ LY_ARRAY_FOR (slist -> uniques , u ) {
1239
+ LY_ARRAY_FOR (slist -> uniques [u ], v ) {
1240
+ if (slist -> uniques [u ][v ] == (struct lysc_node_leaf * )node ) {
1241
+ LOG_LOCSET (node , NULL );
1242
+ LOGVAL (node -> module -> ctx , LYVE_REFERENCE , "Disabled node \"%s\" is referenced as unique in the list \"%s\"." ,
1243
+ node -> name , slist -> name );
1244
+ LOG_LOCBACK (1 , 0 );
1245
+ return LY_EVALID ;
1246
+ }
1247
+ }
1248
+ }
1249
+ }
1250
+
1251
+ return LY_SUCCESS ;
1252
+ }
1253
+
1211
1254
/**
1212
1255
* @brief Finish dependency set compilation by resolving all the unres sets.
1213
1256
*
@@ -1365,13 +1408,9 @@ lys_compile_unres_depset(struct ly_ctx *ctx, struct lys_glob_unres *unres)
1365
1408
/* finally, remove all disabled nodes */
1366
1409
for (i = 0 ; i < ds_unres -> disabled .count ; ++ i ) {
1367
1410
node = ds_unres -> disabled .snodes [i ];
1368
- if (node -> flags & LYS_KEY ) {
1369
- LOG_LOCSET (node , NULL );
1370
- LOGVAL (ctx , LYVE_REFERENCE , "Key \"%s\" is disabled." , node -> name );
1371
- LOG_LOCBACK (1 , 0 );
1372
- ret = LY_EVALID ;
1373
- goto cleanup ;
1374
- }
1411
+ ret = lys_compile_unres_check_disabled (node );
1412
+ LY_CHECK_GOTO (ret , cleanup );
1413
+
1375
1414
LYSC_CTX_INIT_PMOD (cctx , node -> module -> parsed , NULL );
1376
1415
1377
1416
lysc_node_free (& cctx .free_ctx , node , 1 );
0 commit comments