data types BUGFIX resolving derived boolean/empty types

In case of instantiating boolean or empty typedef (not directly these
base types), the type was incorrectly compiled resulting in accessing
freed memory.

Fixes #1042
diff --git a/src/tree_schema_compile.c b/src/tree_schema_compile.c
index 3e0cc12..3199c58 100644
--- a/src/tree_schema_compile.c
+++ b/src/tree_schema_compile.c
@@ -3383,7 +3383,7 @@
         ++(*type)->refcount;
         ret = lys_compile_type_(ctx, context_node_p, context_flags, context_mod, context_name, type_p, ctx->mod_def, basetype, NULL, base, type);
         LY_CHECK_GOTO(ret, cleanup);
-    } else {
+    } else if (basetype != LY_TYPE_BOOL && basetype != LY_TYPE_EMPTY) {
         /* no specific restriction in leaf's type definition, copy from the base */
         free(*type);
         (*type) = base;