schema compile BUGFIX memory leak
Fixes #872
diff --git a/src/tree_schema_compile.c b/src/tree_schema_compile.c
index 3ba39ba..6155ee4 100644
--- a/src/tree_schema_compile.c
+++ b/src/tree_schema_compile.c
@@ -3670,8 +3670,10 @@
/* the dflt member is just filled to avoid getting the default value from the type */
leaf->dflt = (void*)leaf_p->dflt;
ret = lys_compile_node_type(ctx, node_p, &leaf_p->type, leaf);
- leaf->dflt = NULL;
- LY_CHECK_RET(ret);
+ if (ret) {
+ leaf->dflt = NULL;
+ return ret;
+ }
if (leaf_p->dflt) {
struct ly_err_item *err = NULL;