path UPDATE context not required for freeing
diff --git a/src/schema_compile.c b/src/schema_compile.c
index bda517c..fde3128 100644
--- a/src/schema_compile.c
+++ b/src/schema_compile.c
@@ -866,7 +866,7 @@
 
     /* get the target node */
     target = p[LY_ARRAY_COUNT(p) - 1].node;
-    ly_path_free(node->module->ctx, p);
+    ly_path_free(p);
 
     if (!(target->nodetype & (LYS_LEAF | LYS_LEAFLIST))) {
         LOGVAL(ctx->ctx, LYVE_REFERENCE, "Invalid leafref path \"%s\" - target node is %s instead of leaf or leaf-list.",
@@ -1456,7 +1456,7 @@
             ret = ly_path_compile_leafref(cctx.ctx, l->node, cctx.ext, lref->path,
                     (l->node->flags & LYS_IS_OUTPUT) ? LY_PATH_OPER_OUTPUT : LY_PATH_OPER_INPUT, LY_PATH_TARGET_MANY,
                     LY_VALUE_SCHEMA_RESOLVED, lref->prefixes, &path);
-            ly_path_free(l->node->module->ctx, path);
+            ly_path_free(path);
 
             assert(ret != LY_ERECOMPILE);
             if (ret) {