Skip to content
Snippets Groups Projects
Commit f1dfe106 authored by rswindell's avatar rswindell
Browse files

Fix bug introduced in rev 1.142 with the additional/optional arguments to the

yesno() and noyes() methods:
We need to check the argument count before using the second (optional)
argument or else it has some garbage/left-over value from some previous JS
function call. And no, just increasing the argument count in the method table
isn't enough. :-(
Reported by echicken and DaiTengu, thanks!
parent d4772bde
No related branches found
No related tags found
No related merge requests found
...@@ -859,7 +859,7 @@ js_yesno(JSContext *cx, uintN argc, jsval *arglist) ...@@ -859,7 +859,7 @@ js_yesno(JSContext *cx, uintN argc, jsval *arglist)
JSSTRING_TO_MSTRING(cx, js_str, cstr, NULL); JSSTRING_TO_MSTRING(cx, js_str, cstr, NULL);
if(cstr==NULL) if(cstr==NULL)
return JS_FALSE; return JS_FALSE;
if(JSVAL_IS_NUMBER(argv[1])) { if(argc > 1 && JSVAL_IS_NUMBER(argv[1])) {
if(!JS_ValueToInt32(cx, argv[1], &mode)) if(!JS_ValueToInt32(cx, argv[1], &mode))
return JS_FALSE; return JS_FALSE;
} }
...@@ -891,7 +891,7 @@ js_noyes(JSContext *cx, uintN argc, jsval *arglist) ...@@ -891,7 +891,7 @@ js_noyes(JSContext *cx, uintN argc, jsval *arglist)
JSSTRING_TO_MSTRING(cx, js_str, cstr, NULL); JSSTRING_TO_MSTRING(cx, js_str, cstr, NULL);
if(cstr==NULL) if(cstr==NULL)
return JS_FALSE; return JS_FALSE;
if(JSVAL_IS_NUMBER(argv[1])) { if(argc > 1 && JSVAL_IS_NUMBER(argv[1])) {
if(!JS_ValueToInt32(cx, argv[1], &mode)) if(!JS_ValueToInt32(cx, argv[1], &mode))
return JS_FALSE; return JS_FALSE;
} }
...@@ -1985,11 +1985,11 @@ static jsSyncMethodSpec js_console_functions[] = { ...@@ -1985,11 +1985,11 @@ static jsSyncMethodSpec js_console_functions[] = {
,JSDOCSTR("put one or more characters in the keyboard input buffer") ,JSDOCSTR("put one or more characters in the keyboard input buffer")
,310 ,310
}, },
{"yesno", js_yesno, 1, JSTYPE_BOOLEAN, JSDOCSTR("question [,mode = P_NONE]") {"yesno", js_yesno, 2, JSTYPE_BOOLEAN, JSDOCSTR("question [,mode = P_NONE]")
,JSDOCSTR("YES/no question - returns <i>true</i> if 'yes' is selected") ,JSDOCSTR("YES/no question - returns <i>true</i> if 'yes' is selected")
,310 ,310
}, },
{"noyes", js_noyes, 1, JSTYPE_BOOLEAN, JSDOCSTR("question [,mode = P_NONE]") {"noyes", js_noyes, 2, JSTYPE_BOOLEAN, JSDOCSTR("question [,mode = P_NONE]")
,JSDOCSTR("NO/yes question - returns <i>true</i> if 'no' is selected") ,JSDOCSTR("NO/yes question - returns <i>true</i> if 'no' is selected")
,310 ,310
}, },
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment