diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c index 155cfec4d82..8cfeb74d997 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -412,10 +412,6 @@ interpret: /* clear "fork but no exec" flag, as we _are_ execing */ p->p_acflag &= ~AFORK; - /* Set values passed into the program in registers. */ - setregs(td, imgp->entry_addr, (u_long)(uintptr_t)stack_base, - imgp->ps_strings); - /* Free any previous argument cache */ pa = p->p_args; p->p_args = NULL; @@ -423,6 +419,10 @@ interpret: if (pa != NULL && --pa->ar_ref == 0) FREE(pa, M_PARGS); + /* Set values passed into the program in registers. */ + setregs(td, imgp->entry_addr, (u_long)(uintptr_t)stack_base, + imgp->ps_strings); + /* Cache arguments if they fit inside our allowance */ i = imgp->endargs - imgp->stringbase; if (ps_arg_cache_limit >= i + sizeof(struct pargs)) {