mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-11-01 06:58:22 +00:00
waitpid: fix use after free
This commit is contained in:
@@ -75,6 +75,12 @@ syscallret_t syscall_waitpid(context_t *context, pid_t pid, int *status, int opt
|
|||||||
for (int i = 0; i < iterator->threadtablesize; ++i) {
|
for (int i = 0; i < iterator->threadtablesize; ++i) {
|
||||||
if (iterator->threads[i] == NULL)
|
if (iterator->threads[i] == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
volatile int *flags = (volatile int *)(&iterator->threads[i]->flags);
|
||||||
|
// wait until the thread can actually be unallocated
|
||||||
|
while ((*flags & SCHED_THREAD_FLAGS_DEAD) == 0)
|
||||||
|
sched_yield();
|
||||||
|
|
||||||
sched_destroythread(iterator->threads[i]);
|
sched_destroythread(iterator->threads[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user