printer tree BUGFIX possible invalid memory access
diff --git a/src/printer_tree.c b/src/printer_tree.c
index 525e505..b5b9666 100644
--- a/src/printer_tree.c
+++ b/src/printer_tree.c
@@ -3974,7 +3974,7 @@
     ly_parse_nodeid(&id, &prefix, &prefix_len, &name, &name_len);
     if (prefix) {
         mod = ly_resolve_prefix(pmod->mod->ctx, prefix, prefix_len, LY_VALUE_SCHEMA, pmod);
-        ret = mod->parsed == pmod;
+        ret = mod ? (mod->parsed == pmod) : 0;
     } else {
         ret = 1;
     }