data tree BUGFIX wrong variable used
diff --git a/src/tree_data.c b/src/tree_data.c
index 6b5a4e7..758bd2a 100644
--- a/src/tree_data.c
+++ b/src/tree_data.c
@@ -907,7 +907,7 @@
 
     /* find the module */
     if (prefix) {
-        str = strndup(name, name_len);
+        str = strndup(prefix, pref_len);
         module = ly_ctx_get_module_implemented(ctx, str);
         free(str);
         LY_CHECK_ERR_RET(!module, LOGERR(ctx, LY_EINVAL, "Module \"%.*s\" not found.", pref_len, prefix), NULL);