mirror of
https://github.com/darlinghq/darlingserver.git
synced 2024-11-23 12:29:41 +00:00
dtape getters: Return NULL
if input is NULL
Found via UBSAN
This commit is contained in:
parent
a7e054c57e
commit
342245fa21
@ -18,6 +18,9 @@ struct dtape_task {
|
||||
|
||||
__attribute__((always_inline))
|
||||
static dtape_task_t* dtape_task_for_xnu_task(task_t xnu_task) {
|
||||
if (!xnu_task) {
|
||||
return NULL;
|
||||
}
|
||||
return (dtape_task_t*)((char*)xnu_task - offsetof(dtape_task_t, xnu_task));
|
||||
};
|
||||
|
||||
|
@ -42,11 +42,17 @@ struct dtape_thread {
|
||||
|
||||
__attribute__((always_inline))
|
||||
static dtape_thread_t* dtape_thread_for_xnu_thread(thread_t xnu_thread) {
|
||||
if (!xnu_thread) {
|
||||
return NULL;
|
||||
}
|
||||
return (dtape_thread_t*)((char*)xnu_thread - offsetof(dtape_thread_t, xnu_thread));
|
||||
};
|
||||
|
||||
__attribute__((always_inline))
|
||||
static dtape_task_t* dtape_task_for_thread(dtape_thread_t* thread) {
|
||||
if (!thread) {
|
||||
return NULL;
|
||||
}
|
||||
return dtape_task_for_xnu_task(thread->xnu_thread.task);
|
||||
};
|
||||
|
||||
|
@ -414,7 +414,7 @@ void dtape_thread_dying(dtape_thread_t* thread) {
|
||||
|
||||
thread_t current_thread(void) {
|
||||
dtape_thread_t* thread = dtape_hooks->current_thread();
|
||||
return &thread->xnu_thread;
|
||||
return thread ? &thread->xnu_thread : NULL;
|
||||
};
|
||||
|
||||
void (thread_reference)(thread_t thread) {
|
||||
|
Loading…
Reference in New Issue
Block a user