Fixed crash if SDL_GetThreadName() is passed a NULL thread.
This commit is contained in:
parent
b47f785f57
commit
9f90ffbc9f
1 changed files with 17 additions and 5 deletions
|
@ -319,7 +319,9 @@ SDL_CreateThread(int (SDLCALL * fn) (void *),
|
||||||
args = (thread_args *) SDL_malloc(sizeof(*args));
|
args = (thread_args *) SDL_malloc(sizeof(*args));
|
||||||
if (args == NULL) {
|
if (args == NULL) {
|
||||||
SDL_OutOfMemory();
|
SDL_OutOfMemory();
|
||||||
|
if (thread->name) {
|
||||||
SDL_free(thread->name);
|
SDL_free(thread->name);
|
||||||
|
}
|
||||||
SDL_free(thread);
|
SDL_free(thread);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
@ -328,7 +330,9 @@ SDL_CreateThread(int (SDLCALL * fn) (void *),
|
||||||
args->info = thread;
|
args->info = thread;
|
||||||
args->wait = SDL_CreateSemaphore(0);
|
args->wait = SDL_CreateSemaphore(0);
|
||||||
if (args->wait == NULL) {
|
if (args->wait == NULL) {
|
||||||
|
if (thread->name) {
|
||||||
SDL_free(thread->name);
|
SDL_free(thread->name);
|
||||||
|
}
|
||||||
SDL_free(thread);
|
SDL_free(thread);
|
||||||
SDL_free(args);
|
SDL_free(args);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
@ -345,7 +349,9 @@ SDL_CreateThread(int (SDLCALL * fn) (void *),
|
||||||
SDL_SemWait(args->wait);
|
SDL_SemWait(args->wait);
|
||||||
} else {
|
} else {
|
||||||
/* Oops, failed. Gotta free everything */
|
/* Oops, failed. Gotta free everything */
|
||||||
|
if (thread->name) {
|
||||||
SDL_free(thread->name);
|
SDL_free(thread->name);
|
||||||
|
}
|
||||||
SDL_free(thread);
|
SDL_free(thread);
|
||||||
thread = NULL;
|
thread = NULL;
|
||||||
}
|
}
|
||||||
|
@ -372,7 +378,11 @@ SDL_GetThreadID(SDL_Thread * thread)
|
||||||
const char *
|
const char *
|
||||||
SDL_GetThreadName(SDL_Thread * thread)
|
SDL_GetThreadName(SDL_Thread * thread)
|
||||||
{
|
{
|
||||||
|
if (thread) {
|
||||||
return thread->name;
|
return thread->name;
|
||||||
|
} else {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -389,7 +399,9 @@ SDL_WaitThread(SDL_Thread * thread, int *status)
|
||||||
if (status) {
|
if (status) {
|
||||||
*status = thread->status;
|
*status = thread->status;
|
||||||
}
|
}
|
||||||
|
if (thread->name) {
|
||||||
SDL_free(thread->name);
|
SDL_free(thread->name);
|
||||||
|
}
|
||||||
SDL_free(thread);
|
SDL_free(thread);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue