From f1ebce737285df8adcc669641cd5d46a50eb2854 Mon Sep 17 00:00:00 2001
From: "Rob Swindell (on Windows 11)" <rob@synchro.net>
Date: Wed, 22 Nov 2023 15:04:04 -0800
Subject: [PATCH] Fix CID 469135

---
 src/sbbs3/js_rtpool.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/sbbs3/js_rtpool.c b/src/sbbs3/js_rtpool.c
index c069cd20ea..6de34fc2c4 100644
--- a/src/sbbs3/js_rtpool.c
+++ b/src/sbbs3/js_rtpool.c
@@ -32,10 +32,11 @@ JSRuntime * jsrt_GetNew(int maxbytes, unsigned long timeout, const char *filenam
 	if(!initialized) {
 		initialized=TRUE;
 		pthread_mutex_init(&jsrt_mutex, NULL);
+		pthread_mutex_lock(&jsrt_mutex);
 		listInit(&rt_list, 0);
 		_beginthread(trigger_thread, TRIGGER_THREAD_STACK_SIZE, NULL);
-	}
-	pthread_mutex_lock(&jsrt_mutex);
+	} else
+		pthread_mutex_lock(&jsrt_mutex);
 	ret=JS_NewRuntime(maxbytes);
 	listPushNode(&rt_list, ret);
 	pthread_mutex_unlock(&jsrt_mutex);
-- 
GitLab