From 99f648b911d4199944314723d3f3e4f55b844b67 Mon Sep 17 00:00:00 2001 From: Kalle Olavi Niemitalo Date: Sun, 27 May 2007 18:32:53 +0300 Subject: [PATCH] SMJS: Use JS_GetInstancePrivate where applicable. This is a further precaution against reading a pointer from the wrong type of object. All of the JS_GetPrivate calls were already protected with JS_InstanceOf checks if assertions are enabled, and many of them also if assertions are not enabled. --- src/ecmascript/spidermonkey/document.c | 6 ++- src/ecmascript/spidermonkey/form.c | 63 +++++++++++++++++--------- src/ecmascript/spidermonkey/location.c | 6 ++- src/ecmascript/spidermonkey/unibar.c | 6 ++- src/ecmascript/spidermonkey/window.c | 8 ++-- src/scripting/smjs/action_object.c | 6 ++- src/scripting/smjs/bookmarks.c | 9 ++-- src/scripting/smjs/cache_object.c | 9 ++-- src/scripting/smjs/globhist.c | 12 +++-- src/scripting/smjs/keybinding.c | 9 ++-- src/scripting/smjs/view_state_object.c | 6 ++- 11 files changed, 92 insertions(+), 48 deletions(-) diff --git a/src/ecmascript/spidermonkey/document.c b/src/ecmascript/spidermonkey/document.c index 0b481658f..05a75f193 100644 --- a/src/ecmascript/spidermonkey/document.c +++ b/src/ecmascript/spidermonkey/document.c @@ -98,7 +98,8 @@ document_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp) assert(JS_InstanceOf(ctx, parent_win, (JSClass *) &window_class, NULL)); if_assert_failed return JS_FALSE; - vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */ + vs = JS_GetInstancePrivate(ctx, parent_win, + (JSClass *) &window_class, NULL); doc_view = vs->doc_view; document = doc_view->document; ses = doc_view->session; @@ -203,7 +204,8 @@ document_set_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp) assert(JS_InstanceOf(ctx, parent_win, (JSClass *) &window_class, NULL)); if_assert_failed return JS_FALSE; - vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */ + vs = JS_GetInstancePrivate(ctx, parent_win, + (JSClass *) &window_class, NULL); doc_view = vs->doc_view; document = doc_view->document; diff --git a/src/ecmascript/spidermonkey/form.c b/src/ecmascript/spidermonkey/form.c index 0f5b66a5e..3ee459f01 100644 --- a/src/ecmascript/spidermonkey/form.c +++ b/src/ecmascript/spidermonkey/form.c @@ -134,7 +134,9 @@ static unicode_val_T jsval_to_accesskey(JSContext *ctx, jsval *vp); static struct form_state * input_get_form_state(JSContext *ctx, JSObject *obj, struct view_state *vs) { - int n = (int)(long)JS_GetPrivate(ctx, obj); + int n = (int)(long)JS_GetInstancePrivate(ctx, obj, + (JSClass *) &input_class, + NULL); return &vs->form_info[n]; } @@ -169,7 +171,8 @@ input_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp) assert(JS_InstanceOf(ctx, parent_win, (JSClass *) &window_class, NULL)); if_assert_failed return JS_FALSE; - vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */ + vs = JS_GetInstancePrivate(ctx, parent_win, + (JSClass *) &window_class, NULL); doc_view = vs->doc_view; document = doc_view->document; fs = input_get_form_state(ctx, obj, vs); @@ -319,7 +322,8 @@ input_set_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp) assert(JS_InstanceOf(ctx, parent_win, (JSClass *) &window_class, NULL)); if_assert_failed return JS_FALSE; - vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */ + vs = JS_GetInstancePrivate(ctx, parent_win, + (JSClass *) &window_class, NULL); doc_view = vs->doc_view; document = doc_view->document; fs = input_get_form_state(ctx, obj, vs); @@ -442,7 +446,8 @@ input_click(JSContext *ctx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) assert(JS_InstanceOf(ctx, parent_win, (JSClass *) &window_class, NULL)); if_assert_failed return JS_FALSE; - vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */ + vs = JS_GetInstancePrivate(ctx, parent_win, + (JSClass *) &window_class, NULL); doc_view = vs->doc_view; document = doc_view->document; ses = doc_view->session; @@ -494,7 +499,8 @@ input_focus(JSContext *ctx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) assert(JS_InstanceOf(ctx, parent_win, (JSClass *) &window_class, NULL)); if_assert_failed return JS_FALSE; - vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */ + vs = JS_GetInstancePrivate(ctx, parent_win, + (JSClass *) &window_class, NULL); doc_view = vs->doc_view; document = doc_view->document; ses = doc_view->session; @@ -632,10 +638,12 @@ form_elements_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp) assert(JS_InstanceOf(ctx, parent_win, (JSClass *) &window_class, NULL)); if_assert_failed return JS_FALSE; - vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */ + vs = JS_GetInstancePrivate(ctx, parent_win, + (JSClass *) &window_class, NULL); doc_view = vs->doc_view; document = doc_view->document; - form_view = JS_GetPrivate(ctx, parent_form); /* from @form_class */ + form_view = JS_GetInstancePrivate(ctx, parent_form, + (JSClass *) &form_class, NULL); form = find_form_by_form_view(document, form_view); if (JSVAL_IS_STRING(id)) { @@ -688,10 +696,12 @@ form_elements_item(JSContext *ctx, JSObject *obj, uintN argc, jsval *argv, jsval assert(JS_InstanceOf(ctx, parent_win, (JSClass *) &window_class, NULL)); if_assert_failed return JS_FALSE; - vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */ + vs = JS_GetInstancePrivate(ctx, parent_win, + (JSClass *) &window_class, NULL); doc_view = vs->doc_view; document = doc_view->document; - form_view = JS_GetPrivate(ctx, parent_form); /* from @form_class */ + form_view = JS_GetInstancePrivate(ctx, parent_form, + (JSClass *) &form_class, NULL); form = find_form_by_form_view(document, form_view); if (argc != 1) @@ -745,10 +755,12 @@ form_elements_namedItem(JSContext *ctx, JSObject *obj, uintN argc, jsval *argv, assert(JS_InstanceOf(ctx, parent_win, (JSClass *) &window_class, NULL)); if_assert_failed return JS_FALSE; - vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */ + vs = JS_GetInstancePrivate(ctx, parent_win, + (JSClass *) &window_class, NULL); doc_view = vs->doc_view; document = doc_view->document; - form_view = JS_GetPrivate(ctx, parent_form); /* from @form_class */ + form_view = JS_GetInstancePrivate(ctx, parent_form, + (JSClass *) &form_class, NULL); form = find_form_by_form_view(document, form_view); if (argc != 1) @@ -849,9 +861,10 @@ form_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp) assert(JS_InstanceOf(ctx, parent_win, (JSClass *) &window_class, NULL)); if_assert_failed return JS_FALSE; - vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */ + vs = JS_GetInstancePrivate(ctx, parent_win, + (JSClass *) &window_class, NULL); doc_view = vs->doc_view; - fv = JS_GetPrivate(ctx, obj); /* from @form_class */ + fv = JS_GetInstancePrivate(ctx, obj, (JSClass *) &form_class, NULL); form = find_form_by_form_view(doc_view->document, fv); assert(form); @@ -981,9 +994,10 @@ form_set_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp) assert(JS_InstanceOf(ctx, parent_win, (JSClass *) &window_class, NULL)); if_assert_failed return JS_FALSE; - vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */ + vs = JS_GetInstancePrivate(ctx, parent_win, + (JSClass *) &window_class, NULL); doc_view = vs->doc_view; - fv = JS_GetPrivate(ctx, obj); /* from @form_class */ + fv = JS_GetInstancePrivate(ctx, obj, (JSClass *) &form_class, NULL); form = find_form_by_form_view(doc_view->document, fv); assert(form); @@ -1060,9 +1074,10 @@ form_reset(JSContext *ctx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) assert(JS_InstanceOf(ctx, parent_win, (JSClass *) &window_class, NULL)); if_assert_failed return JS_FALSE; - vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */ + vs = JS_GetInstancePrivate(ctx, parent_win, + (JSClass *) &window_class, NULL); doc_view = vs->doc_view; - fv = JS_GetPrivate(ctx, obj); /* from @form_class */ + fv = JS_GetInstancePrivate(ctx, obj, (JSClass *) &form_class, argv); form = find_form_by_form_view(doc_view->document, fv); assert(form); @@ -1095,10 +1110,11 @@ form_submit(JSContext *ctx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) assert(JS_InstanceOf(ctx, parent_win, (JSClass *) &window_class, NULL)); if_assert_failed return JS_FALSE; - vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */ + vs = JS_GetInstancePrivate(ctx, parent_win, + (JSClass *) &window_class, NULL); doc_view = vs->doc_view; ses = doc_view->session; - fv = JS_GetPrivate(ctx, obj); /* from @form_class */ + fv = JS_GetInstancePrivate(ctx, obj, (JSClass *) &form_class, argv); form = find_form_by_form_view(doc_view->document, fv); assert(form); @@ -1181,7 +1197,8 @@ forms_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp) assert(JS_InstanceOf(ctx, parent_win, (JSClass *) &window_class, NULL)); if_assert_failed return JS_FALSE; - vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */ + vs = JS_GetInstancePrivate(ctx, parent_win, + (JSClass *) &window_class, NULL); doc_view = vs->doc_view; document = doc_view->document; @@ -1225,7 +1242,8 @@ forms_item(JSContext *ctx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) assert(JS_InstanceOf(ctx, parent_win, (JSClass *) &window_class, NULL)); if_assert_failed return JS_FALSE; - vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */ + vs = JS_GetInstancePrivate(ctx, parent_win, + (JSClass *) &window_class, NULL); if (argc != 1) return JS_TRUE; @@ -1265,7 +1283,8 @@ forms_namedItem(JSContext *ctx, JSObject *obj, uintN argc, jsval *argv, jsval *r assert(JS_InstanceOf(ctx, parent_win, (JSClass *) &window_class, NULL)); if_assert_failed return JS_FALSE; - vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */ + vs = JS_GetInstancePrivate(ctx, parent_win, + (JSClass *) &window_class, NULL); doc_view = vs->doc_view; document = doc_view->document; diff --git a/src/ecmascript/spidermonkey/location.c b/src/ecmascript/spidermonkey/location.c index e9a2aed71..af90ce631 100644 --- a/src/ecmascript/spidermonkey/location.c +++ b/src/ecmascript/spidermonkey/location.c @@ -164,7 +164,8 @@ location_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp) assert(JS_InstanceOf(ctx, parent_win, (JSClass *) &window_class, NULL)); if_assert_failed return JS_FALSE; - vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */ + vs = JS_GetInstancePrivate(ctx, parent_win, + (JSClass *) &window_class, NULL); if (!JSVAL_IS_INT(id)) return JS_TRUE; @@ -205,7 +206,8 @@ location_set_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp) assert(JS_InstanceOf(ctx, parent_win, (JSClass *) &window_class, NULL)); if_assert_failed return JS_FALSE; - vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */ + vs = JS_GetInstancePrivate(ctx, parent_win, + (JSClass *) &window_class, NULL); doc_view = vs->doc_view; if (!JSVAL_IS_INT(id)) diff --git a/src/ecmascript/spidermonkey/unibar.c b/src/ecmascript/spidermonkey/unibar.c index 081787f90..63e45cb44 100644 --- a/src/ecmascript/spidermonkey/unibar.c +++ b/src/ecmascript/spidermonkey/unibar.c @@ -98,7 +98,8 @@ unibar_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp) assert(JS_InstanceOf(ctx, parent_win, (JSClass *) &window_class, NULL)); if_assert_failed return JS_FALSE; - vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */ + vs = JS_GetInstancePrivate(ctx, parent_win, + (JSClass *) &window_class, NULL); doc_view = vs->doc_view; status = &doc_view->session->status; bar = JS_GetPrivate(ctx, obj); /* from @menubar_class or @statusbar_class */ @@ -156,7 +157,8 @@ unibar_set_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp) assert(JS_InstanceOf(ctx, parent_win, (JSClass *) &window_class, NULL)); if_assert_failed return JS_FALSE; - vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */ + vs = JS_GetInstancePrivate(ctx, parent_win, + (JSClass *) &window_class, NULL); doc_view = vs->doc_view; status = &doc_view->session->status; bar = JS_GetPrivate(ctx, obj); /* from @menubar_class or @statusbar_class */ diff --git a/src/ecmascript/spidermonkey/window.c b/src/ecmascript/spidermonkey/window.c index 09cc05232..1ae68095c 100644 --- a/src/ecmascript/spidermonkey/window.c +++ b/src/ecmascript/spidermonkey/window.c @@ -132,7 +132,7 @@ window_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp) if (!JS_InstanceOf(ctx, obj, (JSClass *) &window_class, NULL)) return JS_FALSE; - vs = JS_GetPrivate(ctx, obj); /* from @window_class */ + vs = JS_GetInstancePrivate(ctx, obj, (JSClass *) &window_class, NULL); /* No need for special window.location measurements - when * location is then evaluated in string context, toString() @@ -264,7 +264,7 @@ window_set_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp) if (!JS_InstanceOf(ctx, obj, (JSClass *) &window_class, NULL)) return JS_FALSE; - vs = JS_GetPrivate(ctx, obj); /* from @window_class */ + vs = JS_GetInstancePrivate(ctx, obj, (JSClass *) &window_class, NULL); if (JSVAL_IS_STRING(id)) { if (!strcmp(jsval_to_string(ctx, &id), "location")) { @@ -318,7 +318,7 @@ window_alert(JSContext *ctx, JSObject *obj, uintN argc, jsval *argv, jsval *rval if (!JS_InstanceOf(ctx, obj, (JSClass *) &window_class, argv)) return JS_FALSE; - vs = JS_GetPrivate(ctx, obj); /* from @window_class */ + vs = JS_GetInstancePrivate(ctx, obj, (JSClass *) &window_class, argv); if (argc != 1) return JS_TRUE; @@ -349,7 +349,7 @@ window_open(JSContext *ctx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) if (!JS_InstanceOf(ctx, obj, (JSClass *) &window_class, argv)) return JS_FALSE; - vs = JS_GetPrivate(ctx, obj); /* from @window_class */ + vs = JS_GetInstancePrivate(ctx, obj, (JSClass *) &window_class, argv); doc_view = vs->doc_view; ses = doc_view->session; diff --git a/src/scripting/smjs/action_object.c b/src/scripting/smjs/action_object.c index 93a255ec0..b3c38dced 100644 --- a/src/scripting/smjs/action_object.c +++ b/src/scripting/smjs/action_object.c @@ -32,7 +32,8 @@ smjs_action_fn_finalize(JSContext *ctx, JSObject *obj) assert(JS_InstanceOf(ctx, obj, (JSClass *) &action_fn_class, NULL)); if_assert_failed return; - hop = JS_GetPrivate(ctx, obj); /* from @action_fn_class */ + hop = JS_GetInstancePrivate(ctx, obj, + (JSClass *) &action_fn_class, NULL); if (hop) mem_free(hop); } @@ -55,7 +56,8 @@ smjs_action_fn_callback(JSContext *ctx, JSObject *obj, uintN argc, jsval *argv, assert(JS_InstanceOf(ctx, fn_obj, (JSClass *) &action_fn_class, NULL)); if_assert_failed return JS_FALSE; - hop = JS_GetPrivate(ctx, fn_obj); /* from @action_fn_class */ + hop = JS_GetInstancePrivate(ctx, fn_obj, + (JSClass *) &action_fn_class, NULL); if (!hop) return JS_TRUE; if (argc >= 1) { diff --git a/src/scripting/smjs/bookmarks.c b/src/scripting/smjs/bookmarks.c index 7731102d2..1d891f12e 100644 --- a/src/scripting/smjs/bookmarks.c +++ b/src/scripting/smjs/bookmarks.c @@ -90,7 +90,8 @@ bookmark_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp) if (!JS_InstanceOf(ctx, obj, (JSClass *) &bookmark_class, NULL)) return JS_FALSE; - bookmark = JS_GetPrivate(ctx, obj); /* from @bookmark_class */ + bookmark = JS_GetInstancePrivate(ctx, obj, + (JSClass *) &bookmark_class, NULL); if (!bookmark) return JS_FALSE; @@ -137,7 +138,8 @@ bookmark_set_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp) if (!JS_InstanceOf(ctx, obj, (JSClass *) &bookmark_class, NULL)) return JS_FALSE; - bookmark = JS_GetPrivate(ctx, obj); /* from @bookmark_class */ + bookmark = JS_GetInstancePrivate(ctx, obj, + (JSClass *) &bookmark_class, NULL); if (!bookmark) return JS_FALSE; @@ -211,7 +213,8 @@ bookmark_folder_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp) if (!JS_InstanceOf(ctx, obj, (JSClass *) &bookmark_folder_class, NULL)) return JS_FALSE; - folder = JS_GetPrivate(ctx, obj); /* from @bookmark_folder_class */ + folder = JS_GetInstancePrivate(ctx, obj, + (JSClass *) &bookmark_folder_class, NULL); *vp = JSVAL_NULL; diff --git a/src/scripting/smjs/cache_object.c b/src/scripting/smjs/cache_object.c index 88c4d7fd0..4c46cfc05 100644 --- a/src/scripting/smjs/cache_object.c +++ b/src/scripting/smjs/cache_object.c @@ -49,7 +49,8 @@ cache_entry_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp) if (!JS_InstanceOf(ctx, obj, (JSClass *) &cache_entry_class, NULL)) return JS_FALSE; - cached = JS_GetPrivate(ctx, obj); /* from @cache_entry_class */ + cached = JS_GetInstancePrivate(ctx, obj, + (JSClass *) &cache_entry_class, NULL); if (!cache_entry_is_valid(cached)) return JS_FALSE; @@ -112,7 +113,8 @@ cache_entry_set_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp) if (!JS_InstanceOf(ctx, obj, (JSClass *) &cache_entry_class, NULL)) return JS_FALSE; - cached = JS_GetPrivate(ctx, obj); /* from @cache_entry_class */ + cached = JS_GetInstancePrivate(ctx, obj, + (JSClass *) &cache_entry_class, NULL); if (!cache_entry_is_valid(cached)) return JS_FALSE; @@ -164,7 +166,8 @@ cache_entry_finalize(JSContext *ctx, JSObject *obj) assert(JS_InstanceOf(ctx, obj, (JSClass *) &cache_entry_class, NULL)); if_assert_failed return; - cached = JS_GetPrivate(ctx, obj); /* from @cache_entry_class */ + cached = JS_GetInstancePrivate(ctx, obj, + (JSClass *) &cache_entry_class, NULL); if (!cached) return; diff --git a/src/scripting/smjs/globhist.c b/src/scripting/smjs/globhist.c index bcc4cad72..211a7a1a7 100644 --- a/src/scripting/smjs/globhist.c +++ b/src/scripting/smjs/globhist.c @@ -25,7 +25,9 @@ smjs_globhist_item_finalize(JSContext *ctx, JSObject *obj) assert(JS_InstanceOf(ctx, obj, (JSClass *) &smjs_globhist_item_class, NULL)); if_assert_failed return; - history_item = JS_GetPrivate(ctx, obj); /* from @smjs_globhist_item_class */ + history_item = JS_GetInstancePrivate(ctx, obj, + (JSClass *) &smjs_globhist_item_class, + NULL); if (history_item) object_unlock(history_item); } @@ -60,7 +62,9 @@ smjs_globhist_item_get_property(JSContext *ctx, JSObject *obj, jsval id, if (!JS_InstanceOf(ctx, obj, (JSClass *) &smjs_globhist_item_class, NULL)) return JS_FALSE; - history_item = JS_GetPrivate(ctx, obj); /* from @smjs_globhist_item_class */ + history_item = JS_GetInstancePrivate(ctx, obj, + (JSClass *) &smjs_globhist_item_class, + NULL); if (!history_item) return JS_FALSE; @@ -123,7 +127,9 @@ smjs_globhist_item_set_property(JSContext *ctx, JSObject *obj, jsval id, jsval * if (!JS_InstanceOf(ctx, obj, (JSClass *) &smjs_globhist_item_class, NULL)) return JS_FALSE; - history_item = JS_GetPrivate(ctx, obj); /* from @smjs_globhist_item_class */ + history_item = JS_GetInstancePrivate(ctx, obj, + (JSClass *) &smjs_globhist_item_class, + NULL); if (!history_item) return JS_FALSE; diff --git a/src/scripting/smjs/keybinding.c b/src/scripting/smjs/keybinding.c index 79c8d0c24..eff4c5450 100644 --- a/src/scripting/smjs/keybinding.c +++ b/src/scripting/smjs/keybinding.c @@ -29,7 +29,8 @@ keymap_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp) if (!JS_InstanceOf(ctx, obj, (JSClass *) &keymap_class, NULL)) return JS_FALSE; - data = JS_GetPrivate(ctx, obj); /* from @keymap_class */ + data = JS_GetInstancePrivate(ctx, obj, + (JSClass *) &keymap_class, NULL); keystroke_str = JS_GetStringBytes(JS_ValueToString(ctx, id)); if (!keystroke_str) goto ret_null; @@ -83,7 +84,8 @@ keymap_set_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp) if (!JS_InstanceOf(ctx, obj, (JSClass *) &keymap_class, NULL)) return JS_FALSE; - data = JS_GetPrivate(ctx, obj); /* from @keymap_class */ + data = JS_GetInstancePrivate(ctx, obj, + (JSClass *) &keymap_class, NULL); /* Ugly fact: we need to get the string from the id to give to bind_do, * which will of course then convert the string back to an id... */ @@ -155,7 +157,8 @@ keymap_finalize(JSContext *ctx, JSObject *obj) assert(JS_InstanceOf(ctx, obj, (JSClass *) &keymap_class, NULL)); if_assert_failed return; - data = JS_GetPrivate(ctx, obj); /* from @keymap_class */ + data = JS_GetInstancePrivate(ctx, obj, + (JSClass *) &keymap_class, NULL); mem_free(data); } diff --git a/src/scripting/smjs/view_state_object.c b/src/scripting/smjs/view_state_object.c index 03b891194..05edf88f7 100644 --- a/src/scripting/smjs/view_state_object.c +++ b/src/scripting/smjs/view_state_object.c @@ -49,7 +49,8 @@ view_state_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp) if (!JS_InstanceOf(ctx, obj, (JSClass *) &view_state_class, NULL)) return JS_FALSE; - vs = JS_GetPrivate(ctx, obj); /* from @view_state_class */ + vs = JS_GetInstancePrivate(ctx, obj, + (JSClass *) &view_state_class, NULL); undef_to_jsval(ctx, vp); @@ -89,7 +90,8 @@ view_state_set_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp) if (!JS_InstanceOf(ctx, obj, (JSClass *) &view_state_class, NULL)) return JS_FALSE; - vs = JS_GetPrivate(ctx, obj); /* from @view_state_class */ + vs = JS_GetInstancePrivate(ctx, obj, + (JSClass *) &view_state_class, NULL); if (!JSVAL_IS_INT(id)) return JS_FALSE;