schema compile CHANGE support for leafref type
diff --git a/src/tree_schema_free.c b/src/tree_schema_free.c
index 7e74603..1e52dd8 100644
--- a/src/tree_schema_free.c
+++ b/src/tree_schema_free.c
@@ -516,6 +516,12 @@
     FREE_ARRAY(ctx, item->exts, lysc_ext_instance_free);
 }
 
+static void lysc_type_free(struct ly_ctx *ctx, struct lysc_type *type);
+static void
+lysc_type2_free(struct ly_ctx *ctx, struct lysc_type **type)
+{
+    lysc_type_free(ctx, *type);
+}
 static void
 lysc_type_free(struct ly_ctx *ctx, struct lysc_type *type)
 {
@@ -552,6 +558,12 @@
     case LY_TYPE_IDENT:
         LY_ARRAY_FREE(((struct lysc_type_identityref*)type)->bases);
         break;
+    case LY_TYPE_UNION:
+        FREE_ARRAY(ctx, ((struct lysc_type_union*)type)->types, lysc_type2_free);
+        break;
+    case LY_TYPE_LEAFREF:
+        FREE_STRING(ctx, ((struct lysc_type_leafref*)type)->path);
+        break;
     case LY_TYPE_INST:
     case LY_TYPE_BOOL:
     case LY_TYPE_EMPTY: