thread: safely return NULL from thread_create() if threads not initialized
This commit is contained in:
parent
83dfe8d5fa
commit
dfa615bb77
1 changed files with 5 additions and 0 deletions
|
@ -134,6 +134,11 @@ static int SDLCALL sdlthread_entry(void *data) {
|
|||
}
|
||||
|
||||
Thread *thread_create(const char *name, ThreadProc proc, void *userdata, ThreadPriority prio) {
|
||||
if(UNLIKELY(!threads.main_id)) {
|
||||
log_error("Thread subsystem is not initialized");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
size_t nsize = strlen(name) + 1;
|
||||
auto thrd = ALLOC_FLEX(Thread, nsize);
|
||||
memcpy(thrd->name, name, nsize);
|
||||
|
|
Loading…
Reference in a new issue