From f6e34d3756ed6a34bae5fdcde4ebd08dd82d9398 Mon Sep 17 00:00:00 2001
From: rswindell <>
Date: Sun, 29 Mar 2020 01:49:16 +0000
Subject: [PATCH] Fix double-free (of startup_dir) in js.exec() method. Improve
 "script missing" error reporting in js.exec().

---
 src/sbbs3/js_internal.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/sbbs3/js_internal.c b/src/sbbs3/js_internal.c
index bd4d599cb8..7fa8ed28a4 100644
--- a/src/sbbs3/js_internal.c
+++ b/src/sbbs3/js_internal.c
@@ -390,7 +390,7 @@ js_execfile(JSContext *cx, uintN argc, jsval *arglist)
 	free(cmd);
 
 	if(!fexistcase(path)) {
-		JS_ReportError(cx, "Can't find script");
+		JS_ReportError(cx, "Script file (%s) does not exist", path);
 		free(startup_dir);
 		return JS_FALSE;
 	}
@@ -449,7 +449,6 @@ js_execfile(JSContext *cx, uintN argc, jsval *arglist)
 	if(js_script == NULL) {
 		/* If the script fails to compile, it's not a fatal error
 		 * for the caller. */
-		free(startup_dir);
 		if (JS_IsExceptionPending(cx)) {
 			JS_GetPendingException(cx, &rval);
 			JS_SET_RVAL(cx, arglist, rval);
-- 
GitLab