@@ -2186,6 +2186,7 @@ fill_yin_deviation(struct lys_module *module, struct lyxml_elem *yin, struct lys
21862186 struct unres_schema tmp_unres ;
21872187 struct lys_module * mod ;
21882188 void * reallocated ;
2189+ size_t deviate_must_index ;
21892190
21902191 GETVAL (ctx , value , yin , "target-node" );
21912192 dev -> target_name = transform_schema2json (module , value );
@@ -2727,10 +2728,10 @@ fill_yin_deviation(struct lys_module *module, struct lyxml_elem *yin, struct lys
27272728 goto error ;
27282729 } else if (d -> mod == LY_DEVIATE_ADD ) {
27292730 /* reallocate the must array of the target */
2730- d -> must = ly_realloc (* trg_must , (c_must + * trg_must_size ) * sizeof * d -> must );
2731- LY_CHECK_ERR_GOTO (!d -> must , LOGMEM (ctx ), error );
2732- * trg_must = d -> must ;
2733- d -> must = & (( * trg_must )[ * trg_must_size ] );
2731+ struct lys_restr * must = ly_realloc (* trg_must , (c_must + * trg_must_size ) * sizeof * d -> must );
2732+ LY_CHECK_ERR_GOTO (!must , LOGMEM (ctx ), error );
2733+ * trg_must = must ;
2734+ d -> must = calloc ( c_must , sizeof * d -> must );
27342735 d -> must_size = c_must ;
27352736 } else { /* LY_DEVIATE_DEL */
27362737 d -> must = calloc (c_must , sizeof * d -> must );
@@ -2824,6 +2825,7 @@ fill_yin_deviation(struct lys_module *module, struct lyxml_elem *yin, struct lys
28242825 }
28252826
28262827 /* process deviation properties with 0..n cardinality */
2828+ deviate_must_index = 0 ;
28272829 LY_TREE_FOR_SAFE (develem -> child , next2 , child ) {
28282830 if (strcmp (child -> ns -> value , LY_NSYIN )) {
28292831 /* extension */
@@ -2879,6 +2881,8 @@ fill_yin_deviation(struct lys_module *module, struct lyxml_elem *yin, struct lys
28792881 if (fill_yin_must (module , child , & ((* trg_must )[* trg_must_size ]), unres )) {
28802882 goto error ;
28812883 }
2884+ memcpy (d -> must + deviate_must_index , & ((* trg_must )[* trg_must_size ]), sizeof * d -> must );
2885+ ++ deviate_must_index ;
28822886 (* trg_must_size )++ ;
28832887 }
28842888
0 commit comments