trees BUGFIX checking failure of the called functions
diff --git a/src/tree_data_helpers.c b/src/tree_data_helpers.c
index c5f3a79..e11815b 100644
--- a/src/tree_data_helpers.c
+++ b/src/tree_data_helpers.c
@@ -256,6 +256,7 @@
     case LYD_ANYDATA_LYB:
         if (value->mem) {
             len = lyd_lyb_data_length(value->mem);
+            LY_CHECK_RET(len == -1, LY_EINVAL);
             t->value.mem = malloc(len);
             LY_CHECK_ERR_RET(!t->value.mem, LOGMEM(LYD_NODE_CTX(trg)), LY_EMEM);
             memcpy(t->value.mem, value->mem, len);