tree data BUGFIX error handling
Refs sysrepo/sysrepo#2977
diff --git a/src/tree_data.c b/src/tree_data.c
index 0be7463..d6a04ff 100644
--- a/src/tree_data.c
+++ b/src/tree_data.c
@@ -330,9 +330,11 @@
/* parse the NETCONF message */
rc = lyd_parse_xml_netconf(ctx, ext, parent, &first, in, parse_opts, val_opts, data_type, &envp, &parsed, &lydctx);
- if (rc && envp) {
- /* special situation when the envelopes were parsed successfully */
- *tree = envp;
+ if (rc) {
+ if (envp) {
+ /* special situation when the envelopes were parsed successfully */
+ *tree = envp;
+ }
goto cleanup;
}