Avoid copying memory if SIGCANCEL is not masked.
This commit is contained in:
parent
880659fe81
commit
8bbeb7e9e0
@ -732,8 +732,12 @@ _setcontext(const ucontext_t *ucp)
|
||||
{
|
||||
ucontext_t uc;
|
||||
|
||||
if (ucp == NULL)
|
||||
return (EINVAL);
|
||||
if (!SIGISMEMBER(uc.uc_sigmask, SIGCANCEL))
|
||||
return __sys_setcontext(ucp);
|
||||
(void) memcpy(&uc, ucp, sizeof(uc));
|
||||
remove_thr_signals(&uc.uc_sigmask);
|
||||
SIGDELSET(uc.uc_sigmask, SIGCANCEL);
|
||||
return __sys_setcontext(&uc);
|
||||
}
|
||||
|
||||
@ -743,7 +747,13 @@ _swapcontext(ucontext_t *oucp, const ucontext_t *ucp)
|
||||
{
|
||||
ucontext_t uc;
|
||||
|
||||
if (oucp == NULL || ucp == NULL)
|
||||
return (EINVAL);
|
||||
if (SIGISMEMBER(ucp->uc_sigmask, SIGCANCEL)) {
|
||||
stdout_debug("remove SIGCANCEL\n");
|
||||
(void) memcpy(&uc, ucp, sizeof(uc));
|
||||
remove_thr_signals(&uc.uc_sigmask);
|
||||
return __sys_swapcontext(oucp, &uc);
|
||||
SIGDELSET(uc.uc_sigmask, SIGCANCEL);
|
||||
ucp = &uc;
|
||||
}
|
||||
return __sys_swapcontext(oucp, ucp);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user