diff --git a/src/proxy/proxy1.c b/src/proxy/proxy1.c
index b05fe8e..cb361dc 100644
--- a/src/proxy/proxy1.c
+++ b/src/proxy/proxy1.c
@@ -25,16 +25,26 @@
 #include "glpios.h"
 #include "proxy.h"
 
+static void hook(void *ptr) {
+      longjmp(*(jmp_buf *)ptr, 1);
+}
+
 void ios_proxy_heur(glp_tree *T)
 {     glp_prob *prob;
-      int j, status;
+      int j, status = 1;
       double *xstar, zstar;
+      jmp_buf jump;
+      ENV ctx;
       /* this heuristic is applied only once on the root level */
       if (!(T->curr->level == 0 && T->curr->solved == 1))
          goto done;
+      xstar = xcalloc(1+T->mip->n, sizeof(double));
+      push_env(&ctx);
+      if(setjmp(jump))
+         goto finish;
+      glp_error_hook(hook, jump);
       prob = glp_create_prob();
       glp_copy_prob(prob, T->mip, 0);
-      xstar = xcalloc(1+prob->n, sizeof(double));
       for (j = 1; j <= prob->n; j++)
          xstar[j] = 0.0;
       if (T->mip->mip_stat != GLP_FEAS)
@@ -48,10 +58,12 @@ void ios_proxy_heur(glp_tree *T)
             T->parm->ps_tm_lim, 1);
          xfree(xinit);
       }
+      glp_delete_prob(prob);
+finish:
+      pop_env(&ctx);
       if (status == 0)
          glp_ios_heur_sol(T, xstar);
       xfree(xstar);
-      glp_delete_prob(prob);
 done: return;
 }
 
