diff --git a/sys/kern/subr_trap.c b/sys/kern/subr_trap.c index ee23726be8d4..6a97779602db 100644 --- a/sys/kern/subr_trap.c +++ b/sys/kern/subr_trap.c @@ -245,10 +245,12 @@ const char * syscallname(struct proc *p, u_int code) { static const char unknown[] = "unknown"; + struct sysentvec *sv; - if (p->p_sysent->sv_syscallnames == NULL) + sv = p->p_sysent; + if (sv->sv_syscallnames == NULL || code >= sv->sv_size) return (unknown); - return (p->p_sysent->sv_syscallnames[code]); + return (sv->sv_syscallnames[code]); } int