From a2d6dc86b0b09664a1782cb6d7c36fb7bd38377f Mon Sep 17 00:00:00 2001 From: "Rob Swindell (on Debian Linux)" <rob@synchro.net> Date: Tue, 6 Aug 2024 18:26:29 -0700 Subject: [PATCH] Better invalid argument reporting (null object) from js_gotoxy() The calling script will still terminate if it does this, but at least the caller will get a useful JS exception. Related to fix for issue #769 --- src/sbbs3/js_console.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/sbbs3/js_console.cpp b/src/sbbs3/js_console.cpp index 09763f5c76..2cb6d000ac 100644 --- a/src/sbbs3/js_console.cpp +++ b/src/sbbs3/js_console.cpp @@ -1931,8 +1931,10 @@ js_gotoxy(JSContext *cx, uintN argc, jsval *arglist) if(JSVAL_IS_OBJECT(argv[0])) { JSObject* obj = JSVAL_TO_OBJECT(argv[0]); - if(obj == nullptr) + if(obj == nullptr) { + JS_ReportError(cx, "invalid object argument in call to %s", __FUNCTION__); return JS_FALSE; + } if(!JS_GetProperty(cx, obj, "x", &val) || !JS_ValueToInt32(cx,val,&x)) return JS_FALSE; -- GitLab