Synchronet now requires the libarchive development package (e.g. libarchive-dev on Debian-based Linux distros, libarchive.org for more info) to build successfully.

Commit 6f83c4ff authored by rswindell's avatar rswindell

Define and use a wrapper for JS_GetInstancePrivate(): js_GetClassPrivate()

Use this in place of JS_GetPrivate() in native class methods that need the
class instance's private data pointer and will do bad things if that pointer
points to something other than what is expected. mcmlxxix (matt) discovered
that using Object.apply(), you can invoke class methods where the 'this'
instance is a different class. This would result in
"Internal Error: No Private Data." or a crash.
So now, gracefully detect this condition and report a meaningful error:
"'<class-name>' instance: No Private Data or Class Mismatch"

Also, important to note: if the method uses JS_THIS_OBJECT to get the JSObject*
to pass to JS_Get*Private, then it must do this *before* it calls JS_SET_RVAL.

From jsapi.h:
 * NB: there is an anti-dependency between JS_CALLEE and JS_SET_RVAL: native
 * methods that may inspect their callee must defer setting their return value
 * until after any such possible inspection. Otherwise the return value will be
 * inspected instead of the callee function object.

The js_crypt*.c files still need this treatment.
parent 3b928469
This diff is collapsed.
......@@ -55,8 +55,6 @@ typedef struct
} private_t;
static const char* getprivate_failure = "line %d %s %s JS_GetPrivate failed";
static void dbprintf(BOOL error, private_t* p, char* fmt, ...)
{
va_list argptr;
......@@ -97,6 +95,8 @@ static void js_finalize_com(JSContext *cx, JSObject *obj)
/* COM Object Methods */
extern JSClass js_com_class;
static JSBool
js_close(JSContext *cx, uintN argc, jsval *arglist)
{
......@@ -106,8 +106,7 @@ js_close(JSContext *cx, uintN argc, jsval *arglist)
JS_SET_RVAL(cx, arglist, JSVAL_VOID);
if((p=(private_t*)JS_GetPrivate(cx,obj))==NULL) {
JS_ReportError(cx,getprivate_failure,WHERE);
if((p=(private_t*)js_GetClassPrivate(cx, obj, &js_com_class))==NULL) {
return(JS_FALSE);
}
......@@ -137,8 +136,7 @@ js_open(JSContext *cx, uintN argc, jsval *arglist)
JS_SET_RVAL(cx, arglist, JSVAL_VOID);
if((p=(private_t*)JS_GetPrivate(cx,obj))==NULL) {
JS_ReportError(cx,getprivate_failure,WHERE);
if((p=(private_t*)js_GetClassPrivate(cx, obj, &js_com_class))==NULL) {
return(JS_FALSE);
}
......@@ -177,8 +175,7 @@ js_send(JSContext *cx, uintN argc, jsval *arglist)
JS_SET_RVAL(cx, arglist, JSVAL_VOID);
if((p=(private_t*)JS_GetPrivate(cx,obj))==NULL) {
JS_ReportError(cx,getprivate_failure,WHERE);
if((p=(private_t*)js_GetClassPrivate(cx, obj, &js_com_class))==NULL) {
return(JS_FALSE);
}
......@@ -219,8 +216,7 @@ js_sendfile(JSContext *cx, uintN argc, jsval *arglist)
JS_SET_RVAL(cx, arglist, JSVAL_VOID);
if((p=(private_t*)JS_GetPrivate(cx,obj))==NULL) {
JS_ReportError(cx,getprivate_failure,WHERE);
if((p=(private_t*)js_GetClassPrivate(cx, obj, &js_com_class))==NULL) {
return(JS_FALSE);
}
......@@ -285,8 +281,7 @@ js_sendbin(JSContext *cx, uintN argc, jsval *arglist)
JS_SET_RVAL(cx, arglist, JSVAL_FALSE);
if((p=(private_t*)JS_GetPrivate(cx,obj))==NULL) {
JS_ReportError(cx,getprivate_failure,WHERE);
if((p=(private_t*)js_GetClassPrivate(cx, obj, &js_com_class))==NULL) {
return(JS_FALSE);
}
......@@ -349,8 +344,7 @@ js_recv(JSContext *cx, uintN argc, jsval *arglist)
JS_SET_RVAL(cx, arglist, JSVAL_VOID);
if((p=(private_t*)JS_GetPrivate(cx,obj))==NULL) {
JS_ReportError(cx,getprivate_failure,WHERE);
if((p=(private_t*)js_GetClassPrivate(cx, obj, &js_com_class))==NULL) {
return(JS_FALSE);
}
......@@ -408,8 +402,7 @@ js_recvline(JSContext *cx, uintN argc, jsval *arglist)
JS_SET_RVAL(cx, arglist, JSVAL_VOID);
if((p=(private_t*)JS_GetPrivate(cx,obj))==NULL) {
JS_ReportError(cx,getprivate_failure,WHERE);
if((p=(private_t*)js_GetClassPrivate(cx, obj, &js_com_class))==NULL) {
return(JS_FALSE);
}
......@@ -470,8 +463,7 @@ js_recvbin(JSContext *cx, uintN argc, jsval *arglist)
JS_SET_RVAL(cx, arglist, INT_TO_JSVAL(-1));
if((p=(private_t*)JS_GetPrivate(cx,obj))==NULL) {
JS_ReportError(cx,getprivate_failure,WHERE);
if((p=(private_t*)js_GetClassPrivate(cx, obj, &js_com_class))==NULL) {
return(JS_FALSE);
}
......
This diff is collapsed.
......@@ -67,8 +67,6 @@ typedef struct
} private_t;
static const char* getprivate_failure = "line %d %s %s JS_GetPrivate failed";
static void dbprintf(BOOL error, private_t* p, char* fmt, ...)
{
va_list argptr;
......@@ -128,6 +126,7 @@ static int fopenflags(char *mode)
/* File Object Methods */
extern JSClass js_file_class;
static JSBool
js_open(JSContext *cx, uintN argc, jsval *arglist)
{
......@@ -141,13 +140,12 @@ js_open(JSContext *cx, uintN argc, jsval *arglist)
private_t* p;
jsrefcount rc;
JS_SET_RVAL(cx, arglist, JSVAL_FALSE);
if((p=(private_t*)JS_GetPrivate(cx,obj))==NULL) {
JS_ReportError(cx,getprivate_failure,WHERE);
if((p=(private_t*)js_GetClassPrivate(cx, obj, &js_file_class))==NULL) {
return(JS_FALSE);
}
JS_SET_RVAL(cx, arglist, JSVAL_FALSE);
if(p->fp!=NULL)
return(JS_TRUE);
......@@ -223,8 +221,8 @@ js_popen(JSContext *cx, uintN argc, jsval *arglist)
JS_SET_RVAL(cx, arglist, JSVAL_FALSE);
if((p=(private_t*)JS_GetPrivate(cx,obj))==NULL) {
JS_ReportError(cx,getprivate_failure,WHERE);
if((p=(private_t*)js_GetClassPrivate(cx, obj, &js_file_class))==NULL) {
return(JS_FALSE);
}
......@@ -269,12 +267,12 @@ js_close(JSContext *cx, uintN argc, jsval *arglist)
private_t* p;
jsrefcount rc;
JS_SET_RVAL(cx, arglist, JSVAL_VOID);
if((p=(private_t*)JS_GetPrivate(cx,obj))==NULL) {
JS_ReportError(cx,getprivate_failure,WHERE);
if((p=(private_t*)js_GetClassPrivate(cx, obj, &js_file_class))==NULL) {
return(JS_FALSE);
}
JS_SET_RVAL(cx, arglist, JSVAL_VOID);
if(p->fp==NULL)
return(JS_TRUE);
......@@ -307,8 +305,7 @@ js_raw_pollin(JSContext *cx, uintN argc, jsval *arglist)
struct timeval tv = {0, 0};
#endif
if((p=(private_t*)JS_GetPrivate(cx,obj))==NULL) {
JS_ReportError(cx,getprivate_failure,WHERE);
if((p=(private_t*)js_GetClassPrivate(cx, obj, &js_file_class))==NULL) {
return(JS_FALSE);
}
......@@ -374,8 +371,8 @@ js_raw_read(JSContext *cx, uintN argc, jsval *arglist)
JS_SET_RVAL(cx, arglist, JSVAL_NULL);
if((p=(private_t*)JS_GetPrivate(cx,obj))==NULL) {
JS_ReportError(cx,getprivate_failure,WHERE);
if((p=(private_t*)js_GetClassPrivate(cx, obj, &js_file_class))==NULL) {
return(JS_FALSE);
}
......@@ -433,8 +430,7 @@ js_read(JSContext *cx, uintN argc, jsval *arglist)
JS_SET_RVAL(cx, arglist, JSVAL_NULL);
if((p=(private_t*)JS_GetPrivate(cx,obj))==NULL) {
JS_ReportError(cx,getprivate_failure,WHERE);
if((p=(private_t*)js_GetClassPrivate(cx, obj, &js_file_class))==NULL) {
return(JS_FALSE);
}
......@@ -525,8 +521,7 @@ js_readln(JSContext *cx, uintN argc, jsval *arglist)
JS_SET_RVAL(cx, arglist, JSVAL_NULL);
if((p=(private_t*)JS_GetPrivate(cx,obj))==NULL) {
JS_ReportError(cx,getprivate_failure,WHERE);
if((p=(private_t*)js_GetClassPrivate(cx, obj, &js_file_class))==NULL) {
return(JS_FALSE);
}
......@@ -584,8 +579,7 @@ js_readbin(JSContext *cx, uintN argc, jsval *arglist)
JS_SET_RVAL(cx, arglist, INT_TO_JSVAL(-1));
if((p=(private_t*)JS_GetPrivate(cx,obj))==NULL) {
JS_ReportError(cx,getprivate_failure,WHERE);
if((p=(private_t*)js_GetClassPrivate(cx, obj, &js_file_class))==NULL) {
return(JS_FALSE);
}
......@@ -674,8 +668,7 @@ js_readall(JSContext *cx, uintN argc, jsval *arglist)
JS_SET_RVAL(cx, arglist, JSVAL_NULL);
if((p=(private_t*)JS_GetPrivate(cx,obj))==NULL) {
JS_ReportError(cx,getprivate_failure,WHERE);
if((p=(private_t*)js_GetClassPrivate(cx, obj, &js_file_class))==NULL) {
return(JS_FALSE);
}
......@@ -773,8 +766,7 @@ js_iniGetValue(JSContext *cx, uintN argc, jsval *arglist)
JS_SET_RVAL(cx, arglist, JSVAL_VOID);
if((p=(private_t*)JS_GetPrivate(cx,obj))==NULL) {
JS_ReportError(cx,getprivate_failure,WHERE);
if((p=(private_t*)js_GetClassPrivate(cx, obj, &js_file_class))==NULL) {
return(JS_FALSE);
}
......@@ -898,8 +890,7 @@ js_iniSetValue_internal(JSContext *cx, JSObject *obj, uintN argc, jsval* argv, s
char* cstr;
time_t tt;
if((p=(private_t*)JS_GetPrivate(cx,obj))==NULL) {
JS_ReportError(cx,getprivate_failure,WHERE);
if((p=(private_t*)js_GetClassPrivate(cx, obj, &js_file_class))==NULL) {
return(JS_FALSE);
}
......@@ -972,8 +963,7 @@ js_iniSetValue(JSContext *cx, uintN argc, jsval *arglist)
str_list_t list;
jsrefcount rc;
if((p=(private_t*)JS_GetPrivate(cx,obj))==NULL) {
JS_ReportError(cx,getprivate_failure,WHERE);
if((p=(private_t*)js_GetClassPrivate(cx, obj, &js_file_class))==NULL) {
return(JS_FALSE);
}
......@@ -1005,8 +995,7 @@ js_iniRemoveKey(JSContext *cx, uintN argc, jsval *arglist)
JS_SET_RVAL(cx, arglist, JSVAL_FALSE);
if((p=(private_t*)JS_GetPrivate(cx,obj))==NULL) {
JS_ReportError(cx,getprivate_failure,WHERE);
if((p=(private_t*)js_GetClassPrivate(cx, obj, &js_file_class))==NULL) {
return(JS_FALSE);
}
......@@ -1062,8 +1051,7 @@ js_iniRemoveSection(JSContext *cx, uintN argc, jsval *arglist)
JS_SET_RVAL(cx, arglist, JSVAL_FALSE);
if((p=(private_t*)JS_GetPrivate(cx,obj))==NULL) {
JS_ReportError(cx,getprivate_failure,WHERE);
if((p=(private_t*)js_GetClassPrivate(cx, obj, &js_file_class))==NULL) {
return(JS_FALSE);
}
......@@ -1108,8 +1096,7 @@ js_iniGetSections(JSContext *cx, uintN argc, jsval *arglist)
JS_SET_RVAL(cx, arglist, JSVAL_NULL);
if((p=(private_t*)JS_GetPrivate(cx,obj))==NULL) {
JS_ReportError(cx,getprivate_failure,WHERE);
if((p=(private_t*)js_GetClassPrivate(cx, obj, &js_file_class))==NULL) {
return(JS_FALSE);
}
......@@ -1156,8 +1143,7 @@ js_iniGetKeys(JSContext *cx, uintN argc, jsval *arglist)
JS_SET_RVAL(cx, arglist, JSVAL_NULL);
if((p=(private_t*)JS_GetPrivate(cx,obj))==NULL) {
JS_ReportError(cx,getprivate_failure,WHERE);
if((p=(private_t*)js_GetClassPrivate(cx, obj, &js_file_class))==NULL) {
return(JS_FALSE);
}
......@@ -1202,8 +1188,7 @@ js_iniGetObject(JSContext *cx, uintN argc, jsval *arglist)
JS_SET_RVAL(cx, arglist, JSVAL_NULL);
if((p=(private_t*)JS_GetPrivate(cx,obj))==NULL) {
JS_ReportError(cx,getprivate_failure,WHERE);
if((p=(private_t*)js_GetClassPrivate(cx, obj, &js_file_class))==NULL) {
return(JS_FALSE);
}
......@@ -1259,8 +1244,7 @@ js_iniSetObject(JSContext *cx, uintN argc, jsval *arglist)
JS_SET_RVAL(cx, arglist, JSVAL_FALSE);
if((p=(private_t*)JS_GetPrivate(cx,obj))==NULL) {
JS_ReportError(cx,getprivate_failure,WHERE);
if((p=(private_t*)js_GetClassPrivate(cx, obj, &js_file_class))==NULL) {
return(JS_FALSE);
}
......@@ -1344,8 +1328,7 @@ js_iniGetAllObjects(JSContext *cx, uintN argc, jsval *arglist)
JS_SET_RVAL(cx, arglist, JSVAL_NULL);
if((p=(private_t*)JS_GetPrivate(cx,obj))==NULL) {
JS_ReportError(cx,getprivate_failure,WHERE);
if((p=(private_t*)js_GetClassPrivate(cx, obj, &js_file_class))==NULL) {
return(JS_FALSE);
}
......@@ -1505,8 +1488,7 @@ js_iniSetAllObjects(JSContext *cx, uintN argc, jsval *arglist)
return JS_FALSE;
}
if((p=(private_t*)JS_GetPrivate(cx,obj))==NULL) {
JS_ReportError(cx,getprivate_failure,WHERE);
if((p=(private_t*)js_GetClassPrivate(cx, obj, &js_file_class))==NULL) {
return(JS_FALSE);
}
......@@ -1593,8 +1575,7 @@ js_raw_write(JSContext *cx, uintN argc, jsval *arglist)
JS_SET_RVAL(cx, arglist, JSVAL_FALSE);
if((p=(private_t*)JS_GetPrivate(cx,obj))==NULL) {
JS_ReportError(cx,getprivate_failure,WHERE);
if((p=(private_t*)js_GetClassPrivate(cx, obj, &js_file_class))==NULL) {
return(JS_FALSE);
}
......@@ -1641,8 +1622,7 @@ js_write(JSContext *cx, uintN argc, jsval *arglist)
JS_SET_RVAL(cx, arglist, JSVAL_FALSE);
if((p=(private_t*)JS_GetPrivate(cx,obj))==NULL) {
JS_ReportError(cx,getprivate_failure,WHERE);
if((p=(private_t*)js_GetClassPrivate(cx, obj, &js_file_class))==NULL) {
return(JS_FALSE);
}
......@@ -1733,8 +1713,7 @@ js_writeln_internal(JSContext *cx, JSObject *obj, jsval *arg, jsval *rval)
*rval = JSVAL_FALSE;
if((p=(private_t*)JS_GetPrivate(cx,obj))==NULL) {
JS_ReportError(cx,getprivate_failure,WHERE);
if((p=(private_t*)js_GetClassPrivate(cx, obj, &js_file_class))==NULL) {
return(JS_FALSE);
}
......@@ -1804,8 +1783,7 @@ js_writebin(JSContext *cx, uintN argc, jsval *arglist)
JS_SET_RVAL(cx, arglist, JSVAL_FALSE);
if((p=(private_t*)JS_GetPrivate(cx,obj))==NULL) {
JS_ReportError(cx,getprivate_failure,WHERE);
if((p=(private_t*)js_GetClassPrivate(cx, obj, &js_file_class))==NULL) {
return(JS_FALSE);
}
......@@ -1901,8 +1879,7 @@ js_writeall(JSContext *cx, uintN argc, jsval *arglist)
JS_SET_RVAL(cx, arglist, JSVAL_FALSE);
if((p=(private_t*)JS_GetPrivate(cx,obj))==NULL) {
JS_ReportError(cx,getprivate_failure,WHERE);
if((p=(private_t*)js_GetClassPrivate(cx, obj, &js_file_class))==NULL) {
return(JS_FALSE);
}
......@@ -1949,8 +1926,7 @@ js_lock(JSContext *cx, uintN argc, jsval *arglist)
JS_SET_RVAL(cx, arglist, JSVAL_FALSE);
if((p=(private_t*)JS_GetPrivate(cx,obj))==NULL) {
JS_ReportError(cx,getprivate_failure,WHERE);
if((p=(private_t*)js_GetClassPrivate(cx, obj, &js_file_class))==NULL) {
return(JS_FALSE);
}
......@@ -1995,8 +1971,7 @@ js_unlock(JSContext *cx, uintN argc, jsval *arglist)
JS_SET_RVAL(cx, arglist, JSVAL_FALSE);
if((p=(private_t*)JS_GetPrivate(cx,obj))==NULL) {
JS_ReportError(cx,getprivate_failure,WHERE);
if((p=(private_t*)js_GetClassPrivate(cx, obj, &js_file_class))==NULL) {
return(JS_FALSE);
}
......@@ -2037,8 +2012,7 @@ js_delete(JSContext *cx, uintN argc, jsval *arglist)
JS_SET_RVAL(cx, arglist, JSVAL_VOID);
if((p=(private_t*)JS_GetPrivate(cx,obj))==NULL) {
JS_ReportError(cx,getprivate_failure,WHERE);
if((p=(private_t*)js_GetClassPrivate(cx, obj, &js_file_class))==NULL) {
return(JS_FALSE);
}
......@@ -2063,8 +2037,7 @@ js_flush(JSContext *cx, uintN argc, jsval *arglist)
JS_SET_RVAL(cx, arglist, JSVAL_VOID);
if((p=(private_t*)JS_GetPrivate(cx,obj))==NULL) {
JS_ReportError(cx,getprivate_failure,WHERE);
if((p=(private_t*)js_GetClassPrivate(cx, obj, &js_file_class))==NULL) {
return(JS_FALSE);
}
......@@ -2087,8 +2060,7 @@ js_rewind(JSContext *cx, uintN argc, jsval *arglist)
JS_SET_RVAL(cx, arglist, JSVAL_VOID);
if((p=(private_t*)JS_GetPrivate(cx,obj))==NULL) {
JS_ReportError(cx,getprivate_failure,WHERE);
if((p=(private_t*)js_GetClassPrivate(cx, obj, &js_file_class))==NULL) {
return(JS_FALSE);
}
......@@ -2115,8 +2087,7 @@ js_truncate(JSContext *cx, uintN argc, jsval *arglist)
JS_SET_RVAL(cx, arglist, JSVAL_VOID);
if((p=(private_t*)JS_GetPrivate(cx,obj))==NULL) {
JS_ReportError(cx,getprivate_failure,WHERE);
if((p=(private_t*)js_GetClassPrivate(cx, obj, &js_file_class))==NULL) {
return(JS_FALSE);
}
......@@ -2145,8 +2116,7 @@ js_clear_error(JSContext *cx, uintN argc, jsval *arglist)
JS_SET_RVAL(cx, arglist, JSVAL_VOID);
if((p=(private_t*)JS_GetPrivate(cx,obj))==NULL) {
JS_ReportError(cx,getprivate_failure,WHERE);
if((p=(private_t*)js_GetClassPrivate(cx, obj, &js_file_class))==NULL) {
return(JS_FALSE);
}
......@@ -2173,8 +2143,7 @@ js_fprintf(JSContext *cx, uintN argc, jsval *arglist)
JS_SET_RVAL(cx, arglist, JSVAL_FALSE);
if((p=(private_t*)JS_GetPrivate(cx,obj))==NULL) {
JS_ReportError(cx,getprivate_failure,WHERE);
if((p=(private_t*)js_GetClassPrivate(cx, obj, &js_file_class))==NULL) {
return(JS_FALSE);
}
......@@ -2239,8 +2208,7 @@ static JSBool js_file_set(JSContext *cx, JSObject *obj, jsid id, JSBool strict,
jsrefcount rc;
char* str = NULL;
if((p=(private_t*)JS_GetPrivate(cx,obj))==NULL) {
JS_ReportError(cx,getprivate_failure,WHERE);
if((p=(private_t*)js_GetClassPrivate(cx, obj, &js_file_class))==NULL) {
return(JS_FALSE);
}
......
......@@ -52,7 +52,9 @@
#ifdef JAVASCRIPT
/* Global Object Properites */
extern JSClass js_global_class;
/* Global Object Properties */
enum {
GLOB_PROP_ERRNO
,GLOB_PROP_ERRNO_STR
......@@ -268,7 +270,7 @@ js_load(JSContext *cx, uintN argc, jsval *arglist)
JS_SET_RVAL(cx, arglist,JSVAL_VOID);
if((p=(global_private_t*)JS_GetPrivate(cx,obj))==NULL)
if((p=(global_private_t*)js_GetClassPrivate(cx, obj, &js_global_class))==NULL)
return(JS_FALSE);
exec_obj=JS_GetScopeChain(cx);
......@@ -1602,7 +1604,7 @@ js_html_encode(JSContext *cx, uintN argc, jsval *arglist)
if(argc==0 || JSVAL_IS_VOID(argv[0]))
return(JS_TRUE);
if((p=(global_private_t*)JS_GetPrivate(cx,obj))==NULL) /* Will this work? Ask DM */
if((p=(global_private_t*)js_GetClassPrivate(cx, obj, &js_global_class))==NULL)
return(JS_FALSE);
JSVALUE_TO_MSTRING(cx, argv[0], inbuf, NULL);
......
......@@ -58,8 +58,6 @@ typedef struct
} privatemsg_t;
static const char* getprivate_failure = "line %d %s %s JS_GetPrivate failed";
JSBool JS_ValueToUint32(JSContext *cx, jsval v, uint32 *ip)
{
jsdouble d;
......@@ -89,6 +87,8 @@ static void js_finalize_msgbase(JSContext *cx, JSObject *obj)
/* Methods */
extern JSClass js_msgbase_class;
static JSBool
js_open(JSContext *cx, uintN argc, jsval *arglist)
{
......@@ -96,8 +96,7 @@ js_open(JSContext *cx, uintN argc, jsval *arglist)
private_t* p;
jsrefcount rc;
if((p=(private_t*)JS_GetPrivate(cx,obj))==NULL) {
JS_ReportError(cx,getprivate_failure,WHERE);
if((p=(private_t*)js_GetClassPrivate(cx, obj, &js_msgbase_class))==NULL) {
return JS_FALSE;
}
......@@ -129,8 +128,7 @@ js_close(JSContext *cx, uintN argc, jsval *arglist)
private_t* p;
jsrefcount rc;
if((p=(private_t*)JS_GetPrivate(cx,obj))==NULL) {
JS_ReportError(cx,getprivate_failure,WHERE);
if((p=(private_t*)js_GetClassPrivate(cx, obj, &js_msgbase_class))==NULL) {
return JS_FALSE;
}
......@@ -1105,8 +1103,7 @@ js_get_msg_index(JSContext *cx, uintN argc, jsval *arglist)
JS_SET_RVAL(cx, arglist, JSVAL_NULL);
if((p=(private_t*)JS_GetPrivate(cx,obj))==NULL) {
JS_ReportError(cx,getprivate_failure,WHERE);
if((p=(private_t*)js_GetClassPrivate(cx, obj, &js_msgbase_class))==NULL) {
return JS_FALSE;
}
......@@ -1178,8 +1175,7 @@ js_get_index(JSContext *cx, uintN argc, jsval *arglist)
JS_SET_RVAL(cx, arglist, OBJECT_TO_JSVAL(array));
if((priv=(private_t*)JS_GetPrivate(cx,obj))==NULL) {
JS_ReportError(cx,getprivate_failure,WHERE);
if((priv=(private_t*)js_GetClassPrivate(cx, obj, &js_msgbase_class))==NULL) {
return JS_FALSE;
}
......@@ -1683,8 +1679,7 @@ js_get_msg_header(JSContext *cx, uintN argc, jsval *arglist)
memset(p,0,sizeof(privatemsg_t));
if((p->p=(private_t*)JS_GetPrivate(cx,obj))==NULL) {
JS_ReportError(cx,getprivate_failure,WHERE);
if((p->p=(private_t*)js_GetClassPrivate(cx, obj, &js_msgbase_class))==NULL) {
free(p);
return JS_FALSE;
}
......@@ -1823,8 +1818,7 @@ js_get_all_msg_headers(JSContext *cx, uintN argc, jsval *arglist)
JS_SET_RVAL(cx, arglist, JSVAL_NULL);
if((priv=(private_t*)JS_GetPrivate(cx,obj))==NULL) {
JS_ReportError(cx,getprivate_failure,WHERE);
if((priv=(private_t*)js_GetClassPrivate(cx, obj, &js_msgbase_class))==NULL) {
return JS_FALSE;
}
......@@ -2005,8 +1999,7 @@ js_put_msg_header(JSContext *cx, uintN argc, jsval *arglist)
JS_SET_RVAL(cx, arglist, JSVAL_FALSE);
if((p=(private_t*)JS_GetPrivate(cx,obj))==NULL) {
JS_ReportError(cx,getprivate_failure,WHERE);
if((p=(private_t*)js_GetClassPrivate(cx, obj, &js_msgbase_class))==NULL) {
return JS_FALSE;
}
......@@ -2117,8 +2110,7 @@ js_remove_msg(JSContext *cx, uintN argc, jsval *arglist)
JS_SET_RVAL(cx, arglist, JSVAL_FALSE);
if((p=(private_t*)JS_GetPrivate(cx,obj))==NULL) {
JS_ReportError(cx,getprivate_failure,WHERE);
if((p=(private_t*)js_GetClassPrivate(cx, obj, &js_msgbase_class))==NULL) {
return JS_FALSE;
}
......@@ -2259,8 +2251,7 @@ js_get_msg_body(JSContext *cx, uintN argc, jsval *arglist)
JS_SET_RVAL(cx, arglist, JSVAL_NULL);
if((p=(private_t*)JS_GetPrivate(cx,obj))==NULL) {
JS_ReportError(cx,getprivate_failure,WHERE);
if((p=(private_t*)js_GetClassPrivate(cx, obj, &js_msgbase_class))==NULL) {
return JS_FALSE;
}
......@@ -2374,8 +2365,7 @@ js_get_msg_tail(JSContext *cx, uintN argc, jsval *arglist)
JS_SET_RVAL(cx, arglist, JSVAL_NULL);
if((p=(private_t*)JS_GetPrivate(cx,obj))==NULL) {
JS_ReportError(cx,getprivate_failure,WHERE);
if((p=(private_t*)js_GetClassPrivate(cx, obj, &js_msgbase_class))==NULL) {
return JS_FALSE;
}
......@@ -2484,8 +2474,7 @@ js_save_msg(JSContext *cx, uintN argc, jsval *arglist)
if(argc<2)
return JS_TRUE;
if((p=(private_t*)JS_GetPrivate(cx,obj))==NULL) {
JS_ReportError(cx,getprivate_failure,WHERE);
if((p=(private_t*)js_GetClassPrivate(cx, obj, &js_msgbase_class))==NULL) {
return JS_FALSE;
}
......@@ -2634,8 +2623,7 @@ js_vote_msg(JSContext *cx, uintN argc, jsval *arglist)
if(argc < 1)
return JS_TRUE;
if((p=(private_t*)JS_GetPrivate(cx, obj)) == NULL) {
JS_ReportError(cx, getprivate_failure, WHERE);
if((p=(private_t*)js_GetClassPrivate(cx, obj, &js_msgbase_class)) == NULL) {
return JS_FALSE;
}
......@@ -2702,8 +2690,7 @@ js_add_poll(JSContext *cx, uintN argc, jsval *arglist)
if(argc < 1)
return JS_TRUE;
if((p=(private_t*)JS_GetPrivate(cx,obj)) == NULL) {
JS_ReportError(cx, getprivate_failure, WHERE);
if((p=(private_t*)js_GetClassPrivate(cx, obj, &js_msgbase_class)) == NULL) {
return JS_FALSE;
}
......@@ -2762,8 +2749,7 @@ js_how_user_voted(JSContext *cx, uintN argc, jsval *arglist)