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

Don't call JS_IsArraryObject() with a NULL argument (causes exception).

This should fix Matt's problem with crashes when calling File.writeAll() with a
null value and other potential occurances of the same bug.
parent 60eac7a6
Branches
Tags
No related merge requests found
......@@ -1064,6 +1064,20 @@ js_iniGetAllObjects(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval
JS_RESUMEREQUEST(cx, rc);
val=OBJECT_TO_JSVAL(object);
/* exception here, Apr-4-2010:
2000007a()
js_iniGetAllObjects(JSContext * 0x049383e0, JSObject * 0x049c76a8, unsigned int 0x00000001, long * 0x049c0490, long * 0x02c5c494) line 1064 + 24 bytes
js_Invoke(JSContext * 0x049383e0, unsigned int 0x00000001, unsigned int 0x00000000) line 1375 + 23 bytes
js_Interpret(JSContext * 0x049383e0, unsigned char * 0x031ab4b2, long * 0x02c5d6ac) line 3944 + 15 bytes
js_Execute(JSContext * 0x049383e0, JSObject * 0x049b73e8, JSScript * 0x02f2a7e0, JSStackFrame * 0x00000000, unsigned int 0x00000000, long * 0x02c5d7bc) line 1633 + 19 bytes
JS_ExecuteScript(JSContext * 0x049383e0, JSObject * 0x049b73e8, JSScript * 0x02f2a7e0, long * 0x02c5d7bc) line 4188 + 25 bytes
sbbs_t::js_execfile(const char * 0x0226b59a, const char * 0x022060fa) line 668 + 39 bytes
sbbs_t::external(const char * 0x0226b599, long 0x00000100, const char * 0x022060fa) line 413 + 30 bytes
event_thread(void * 0x022622b8) line 2745 + 113 bytes
_threadstart(void * 0x0227dab0) line 187 + 13 bytes
*/
if(!JS_SetElement(cx, array, i, &val))
break;
}
......@@ -1091,7 +1105,7 @@ js_iniSetAllObjects(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval
*rval = JSVAL_FALSE;
if(!JSVAL_IS_OBJECT(argv[0]))
if(JSVAL_IS_NULL(argv[0]) || !JSVAL_IS_OBJECT(argv[0]))
return(JS_TRUE);
array = JSVAL_TO_OBJECT(argv[0]);
......@@ -1279,7 +1293,7 @@ js_writebin(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
if(p->fp==NULL)
return(JS_TRUE);
if(JSVAL_IS_OBJECT(argv[0])) {
if(JSVAL_IS_OBJECT(argv[0]) && !JSVAL_IS_NULL(argv[0])) {
array = JSVAL_TO_OBJECT(argv[0]);
if(JS_IsArrayObject(cx, array)) {
if(!JS_GetArrayLength(cx, array, &count))
......@@ -1374,7 +1388,7 @@ js_writeall(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
if(p->fp==NULL)
return(JS_TRUE);
if(!JSVAL_IS_OBJECT(argv[0]))
if(JSVAL_IS_NULL(argv[0]) || !JSVAL_IS_OBJECT(argv[0]))
return(JS_TRUE);
array = JSVAL_TO_OBJECT(argv[0]);
......
......@@ -8,7 +8,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Copyright 2009 Rob Swindell - http://www.synchro.net/copyright.html *
* Copyright 2010 Rob Swindell - http://www.synchro.net/copyright.html *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
......@@ -1476,7 +1476,7 @@ js_save_msg(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
memset(&msg,0,sizeof(msg));
for(n=0;n<argc;n++) {
if(JSVAL_IS_OBJECT(argv[n])) {
if(JSVAL_IS_OBJECT(argv[n]) && !JSVAL_IS_NULL(argv[n])) {
objarg = JSVAL_TO_OBJECT(argv[n]);
if((cl=JS_GetClass(cx,objarg))!=NULL && strcmp(cl->name,"Client")==0) {
client=JS_GetPrivate(cx,objarg);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment