schema compile BUGFIX restore context modules
diff --git a/src/schema_compile_amend.c b/src/schema_compile_amend.c
index 168d87d..63d516b 100644
--- a/src/schema_compile_amend.c
+++ b/src/schema_compile_amend.c
@@ -1769,6 +1769,8 @@
     }
 
 cleanup:
+    ctx->cur_mod = orig_mod;
+    ctx->pmod = orig_pmod;
     if (ret) {
         lysp_dev_node_free(ctx->ctx, *dev_pnode);
         *dev_pnode = NULL;