1
0
Fork 0
mirror of https://github.com/bjornbytes/lovr.git synced 2024-07-03 21:13:42 +00:00

Fix crash on non-string thread errors;

Non-string errors are currently ignored.  This is consistent with
love, and is pretty obscure, but maybe it can be improved at some point.
This commit is contained in:
bjorn 2020-12-11 04:41:48 -07:00
parent 8ef50b5f6a
commit e887d46256

View file

@ -38,10 +38,12 @@ static int threadRunner(void* data) {
} }
} }
mtx_lock(&thread->lock);
// Error handling // Error handling
size_t length; size_t length;
const char* error = lua_tolstring(L, -1, &length); const char* error = lua_tolstring(L, -1, &length);
mtx_lock(&thread->lock); if (error) {
thread->error = malloc(length + 1); thread->error = malloc(length + 1);
if (thread->error) { if (thread->error) {
memcpy(thread->error, error, length + 1); memcpy(thread->error, error, length + 1);
@ -50,6 +52,8 @@ static int threadRunner(void* data) {
.data.thread = { thread, thread->error } .data.thread = { thread, thread->error }
}); });
} }
}
thread->running = false; thread->running = false;
mtx_unlock(&thread->lock); mtx_unlock(&thread->lock);
lovrRelease(Thread, thread); lovrRelease(Thread, thread);