validation BUGFIX handle empty tree
Fixes sysrepo/sysrepo#3304
diff --git a/src/validation.c b/src/validation.c
index ecba13d..501dd69 100644
--- a/src/validation.c
+++ b/src/validation.c
@@ -1924,7 +1924,7 @@
uint32_t i = 0;
LY_CHECK_ARG_RET(NULL, module, !(val_opts & (LYD_VALIDATE_PRESENT | LYD_VALIDATE_NOT_FINAL)), LY_EINVAL);
- LY_CHECK_CTX_EQUAL_RET(LYD_CTX(tree), module->ctx, LY_EINVAL);
+ LY_CHECK_CTX_EQUAL_RET(tree ? LYD_CTX(tree) : NULL, module->ctx, LY_EINVAL);
/* module is unchanged but we need to get the first module data node */
mod = lyd_mod_next_module(tree, module, module->ctx, &i, &first);