From 555dbf7da081954f95990a7325bb9b18e76c78c5 Mon Sep 17 00:00:00 2001 From: Kalle Olavi Niemitalo Date: Fri, 11 Jul 2008 16:37:44 +0300 Subject: [PATCH] Bug 1027, SMJS: make null mean "none" in elinks.keymaps elinks.keymaps.main["/"] = null; used to crash ELinks with a segfault in JS_ObjectIsFunction. Fix that by recognizing JSVAL_NULL explicitly and treating it as "none". Likewise, if keymap_get_property would return "none" to ECMAScript, return JSVAL_NULL instead. --- NEWS | 2 ++ src/scripting/smjs/keybinding.c | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index afa03da93..58b5e9b89 100644 --- a/NEWS +++ b/NEWS @@ -10,6 +10,8 @@ ELinks 0.11.4.GIT now: To be released as 0.11.5. +* critical bug 1027 in user SMJS: make elinks.keymaps treat null and + "none" as equivalent actions, avoiding a segfault * build bug 1021: fixed uninitialized variable in http_got_header ELinks 0.11.4: diff --git a/src/scripting/smjs/keybinding.c b/src/scripting/smjs/keybinding.c index 6413d4ed6..cbc992b5f 100644 --- a/src/scripting/smjs/keybinding.c +++ b/src/scripting/smjs/keybinding.c @@ -37,7 +37,7 @@ keymap_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp) action_str = get_action_name_from_keystroke((enum keymap_id) *data, keystroke_str); - if (!action_str) goto ret_null; + if (!action_str || !strcmp(action_str, "none")) goto ret_null; *vp = STRING_TO_JSVAL(JS_NewStringCopyZ(ctx, action_str)); @@ -106,6 +106,12 @@ keymap_set_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp) return JS_TRUE; + } else if (JSVAL_IS_NULL(*vp)) { /* before JSVAL_IS_OBJECT */ + if (bind_do(keymap_str, keystroke_str, "none", 0)) + return JS_FALSE; + + return JS_TRUE; + } else if (JSVAL_IS_OBJECT(*vp)) { unsigned char *err = NULL; int event_id;