From bac71b8d5829012b1ea8f903d4f4dbd75daa3b47 Mon Sep 17 00:00:00 2001 From: Shpoike Date: Tue, 27 Apr 2021 19:45:48 +0100 Subject: [PATCH] Avoid mutex deadlock in an error path. --- engine/gl/gl_model.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/engine/gl/gl_model.c b/engine/gl/gl_model.c index b3a8033c..8b1e16c9 100644 --- a/engine/gl/gl_model.c +++ b/engine/gl/gl_model.c @@ -866,9 +866,17 @@ model_t *Mod_FindName (const char *name) { #endif if (mod_numknown == MAX_MOD_KNOWN) + { + Sys_UnlockMutex(com_resourcemutex); Sys_Error ("mod_numknown == MAX_MOD_KNOWN"); + return NULL; + } if (strlen(name) >= sizeof(mod->publicname)) + { + Sys_UnlockMutex(com_resourcemutex); Sys_Error ("model name is too long: %s", name); + return NULL; + } memset(mod, 0, sizeof(model_t)); //clear the old model as the renderers use the same globals Q_strncpyz (mod->publicname, name, sizeof(mod->publicname)); Q_strncpyz (mod->name, name, sizeof(mod->name));