From cc736811b95483b9e3c3ef03d58932716ae453e7 Mon Sep 17 00:00:00 2001 From: Kimplul Date: Sun, 14 Jul 2024 12:40:53 +0300 Subject: add more checks to getting tcb --- src/tcb.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/tcb.c') diff --git a/src/tcb.c b/src/tcb.c index 48f1d3b..506b756 100644 --- a/src/tcb.c +++ b/src/tcb.c @@ -369,7 +369,14 @@ struct tcb *get_tcb(id_t tid) if (tid <= 0) return NULL; - return tcbs[tid & (num_tids - 1)]; + struct tcb *t = tcbs[tid & (num_tids - 1)]; + if (!t) + return NULL; + + if (t->tid != tid) + return NULL; + + return t; } void set_return(struct tcb *t, vm_t v) -- cgit v1.3