data tree BUGFIX avoid freeing empty values
diff --git a/src/tree_data.c b/src/tree_data.c
index 31b53b1..b809c65 100644
--- a/src/tree_data.c
+++ b/src/tree_data.c
@@ -1207,7 +1207,9 @@
     } /* else value changed, LY_SUCCESS */
 
 cleanup:
-    type->plugin->free(LYD_CTX(term), &val);
+    if (val.realtype) {
+        type->plugin->free(LYD_CTX(term), &val);
+    }
     return ret;
 }