From b6062fa38882d4e96f31772cc57dead251d92370 Mon Sep 17 00:00:00 2001 From: "Rob Swindell (on Windows 11)" <rob@synchro.net> Date: Fri, 6 Dec 2024 12:27:58 -0800 Subject: [PATCH] More nodefile_mutex fixes Need to unlock the mutex before calling errormsg(). Need unlock the mutex in error path of unlocknodedat(). I'm not clear why this would, but it might resolve CID 515601 which looks like false positive to me: getnmsg()->putnodedat() should never leave nodefile_mutex locked. --- src/sbbs3/putnode.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/sbbs3/putnode.cpp b/src/sbbs3/putnode.cpp index 6ebebb432c..7dfcd88b33 100644 --- a/src/sbbs3/putnode.cpp +++ b/src/sbbs3/putnode.cpp @@ -66,8 +66,8 @@ bool sbbs_t::putnodedat(uint number, node_t* node) pthread_mutex_lock(&nodefile_mutex); if(nodefile==-1) { if((nodefile=nopen(path,O_CREAT|O_RDWR|O_DENYNONE))==-1) { - errormsg(WHERE,ERR_OPEN,path,O_CREAT|O_RDWR|O_DENYNONE); pthread_mutex_unlock(&nodefile_mutex); + errormsg(WHERE,ERR_OPEN,path,O_CREAT|O_RDWR|O_DENYNONE); return false; } } @@ -99,6 +99,7 @@ bool sbbs_t::putnodedat(uint number, node_t* node) bool sbbs_t::unlocknodedat(uint number) { if(number < 1 || number > cfg.sys_nodes) { + pthread_mutex_unlock(&nodefile_mutex); errormsg(WHERE, ERR_CHK, "node number", number); return false; } -- GitLab