data tree BUGFIX null pointer access
diff --git a/src/tree_data.c b/src/tree_data.c
index 91d69a9..85261df 100644
--- a/src/tree_data.c
+++ b/src/tree_data.c
@@ -2899,7 +2899,7 @@
         return LY_SUCCESS;
     }
 
-    if (lysc_data_parent((*target)->schema) || lysc_data_parent(source->schema)) {
+    if ((*target && lysc_data_parent((*target)->schema)) || lysc_data_parent(source->schema)) {
         LOGERR(LYD_CTX(source), LY_EINVAL, "Invalid arguments - can merge only 2 top-level subtrees (%s()).", __func__);
         return LY_EINVAL;
     }