From 82db1ea88dec2117ea6a5110a443cc8f69e99fad Mon Sep 17 00:00:00 2001 From: rswindell <> Date: Mon, 20 May 2019 06:59:56 +0000 Subject: [PATCH] Fix require(): if load() fails with exception, don't report a "symbol not defined" exception, just report the load() exception - whatever it was (e.g. could not open load-file). --- src/sbbs3/js_global.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/sbbs3/js_global.c b/src/sbbs3/js_global.c index 90d7b5a324..c30155c6b9 100644 --- a/src/sbbs3/js_global.c +++ b/src/sbbs3/js_global.c @@ -723,12 +723,13 @@ js_require(JSContext *cx, uintN argc, jsval *arglist) ret = js_load(cx, argc-1, arglist); - // TODO: this error is happening if the file doesn't exist! - if (!JS_HasProperty(cx, exec_obj, property, &found) || !found) { - JSVALUE_TO_MSTRING(cx, argv[fnarg], filename, NULL); - JS_ReportError(cx,"symbol '%s' not defined by script '%s'", property, filename); - free(filename); - return(JS_FALSE); + if (!JS_IsExceptionPending(cx)) { + if (!JS_HasProperty(cx, exec_obj, property, &found) || !found) { + JSVALUE_TO_MSTRING(cx, argv[fnarg], filename, NULL); + JS_ReportError(cx,"symbol '%s' not defined by script '%s'", property, filename); + free(filename); + return(JS_FALSE); + } } free(property); return ret; -- GitLab