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 c1fdb1b1 authored by deuce's avatar deuce

Check the return of JS_ValueToInt32() and return false in method/property

functions when an excpetion is pending.

Some work still needs to be done on js_msgbase.c,  js_user.c, and mailsrvr.c
parent 7db0c730
......@@ -278,10 +278,14 @@ js_sendbin(JSContext *cx, uintN argc, jsval *arglist)
return(JS_FALSE);
}
if(argc && argv[0]!=JSVAL_VOID)
JS_ValueToInt32(cx,argv[0],&val);
if(argc>1 && argv[1]!=JSVAL_VOID)
JS_ValueToInt32(cx,argv[1],(int32*)&size);
if(argc && argv[0]!=JSVAL_VOID) {
if(!JS_ValueToInt32(cx,argv[0],&val))
return JS_FALSE;
}
if(argc>1 && argv[1]!=JSVAL_VOID) {
if(!JS_ValueToInt32(cx,argv[1],(int32*)&size))
return JS_FALSE;
}
rc=JS_SUSPENDREQUEST(cx);
switch(size) {
......@@ -338,11 +342,15 @@ js_recv(JSContext *cx, uintN argc, jsval *arglist)
return(JS_FALSE);
}
if(argc && argv[0]!=JSVAL_VOID)
JS_ValueToInt32(cx,argv[0],&len);
if(argc && argv[0]!=JSVAL_VOID) {
if(!JS_ValueToInt32(cx,argv[0],&len))
return JS_FALSE;
}
if(argc>1 && argv[1]!=JSVAL_VOID)
JS_ValueToInt32(cx,argv[1],&timeout);
if(argc>1 && argv[1]!=JSVAL_VOID) {
if(!JS_ValueToInt32(cx,argv[1],&timeout))
return JS_FALSE;
}
if((buf=(char*)alloca(len+1))==NULL) {
JS_ReportError(cx,"Error allocating %u bytes",len+1);
......@@ -391,16 +399,20 @@ js_recvline(JSContext *cx, uintN argc, jsval *arglist)
return(JS_FALSE);
}
if(argc && argv[0]!=JSVAL_VOID)
JS_ValueToInt32(cx,argv[0],&len);
if(argc && argv[0]!=JSVAL_VOID) {
if(!JS_ValueToInt32(cx,argv[0],&len))
return JS_FALSE;
}
if((buf=(char*)alloca(len+1))==NULL) {
JS_ReportError(cx,"Error allocating %u bytes",len+1);
return(JS_FALSE);
}
if(argc>1 && argv[1]!=JSVAL_VOID)
JS_ValueToInt32(cx,argv[1],&timeout);
if(argc>1 && argv[1]!=JSVAL_VOID) {
if(!JS_ValueToInt32(cx,argv[1],&timeout))
return JS_FALSE;
}
rc=JS_SUSPENDREQUEST(cx);
......@@ -446,11 +458,15 @@ js_recvbin(JSContext *cx, uintN argc, jsval *arglist)
return(JS_FALSE);
}
if(argc && argv[0]!=JSVAL_VOID)
JS_ValueToInt32(cx,argv[0],(int32*)&size);
if(argc && argv[0]!=JSVAL_VOID) {
if(!JS_ValueToInt32(cx,argv[0],(int32*)&size))
return JS_FALSE;
}
if(argc>1 && argv[1]!=JSVAL_VOID)
JS_ValueToInt32(cx,argv[1],&timeout);
if(argc>1 && argv[1]!=JSVAL_VOID) {
if(!JS_ValueToInt32(cx,argv[1],&timeout));
return JS_FALSE;
}
rc=JS_SUSPENDREQUEST(cx);
switch(size) {
......@@ -541,11 +557,13 @@ static JSBool js_com_set(JSContext *cx, JSObject *obj, jsid id, JSBool strict, j
JS_ValueToBoolean(cx,*vp,&(p->debug));
break;
case COM_PROP_DESCRIPTOR:
JS_ValueToInt32(cx,*vp,(int32*)&(p->com));
if(!JS_ValueToInt32(cx,*vp,(int32*)&(p->com)))
return JS_FALSE;
p->is_open=TRUE;
break;
case COM_PROP_LAST_ERROR:
JS_ValueToInt32(cx,*vp,(int32*)&(p->last_error));
if(!JS_ValueToInt32(cx,*vp,(int32*)&(p->last_error)))
return JS_FALSE;
break;
case COM_PROP_BAUD_RATE:
JS_ValueToNumber(cx,*vp,&d);
......
......@@ -185,41 +185,49 @@ static JSBool js_set(JSContext *cx, JSObject *obj, jsid id, JSBool strict, jsval
JS_ValueToBoolean(cx, *vp, &puttext_can_move);
break;
case PROP_ESCDELAY:
if(cio_api.ESCDELAY)
JS_ValueToInt32(cx, *vp, (int32*)cio_api.ESCDELAY);
if(cio_api.ESCDELAY) {
if(!JS_ValueToInt32(cx, *vp, (int32*)cio_api.ESCDELAY))
return JS_FALSE;
}
break;
case PROP_TEXTATTR:
JS_ValueToInt32(cx, *vp, &i);
if(!JS_ValueToInt32(cx, *vp, &i))
return JS_FALSE;
rc=JS_SUSPENDREQUEST(cx);
textattr(i);
JS_RESUMEREQUEST(cx, rc);
break;
case PROP_WHEREX:
JS_ValueToInt32(cx, *vp, &i);
if(!JS_ValueToInt32(cx, *vp, &i))
return JS_FALSE;
rc=JS_SUSPENDREQUEST(cx);
gotoxy(i, cio_textinfo.cury);
JS_RESUMEREQUEST(cx, rc);
break;
case PROP_WHEREY:
JS_ValueToInt32(cx, *vp, &i);
if(!JS_ValueToInt32(cx, *vp, &i))
return JS_FALSE;
rc=JS_SUSPENDREQUEST(cx);
gotoxy(cio_textinfo.curx, i);
JS_RESUMEREQUEST(cx, rc);
break;
case PROP_TEXTMODE:
JS_ValueToInt32(cx, *vp, &i);
if(!JS_ValueToInt32(cx, *vp, &i))
return JS_FALSE;
rc=JS_SUSPENDREQUEST(cx);
textmode(i);
JS_RESUMEREQUEST(cx, rc);
break;
case PROP_TEXTBACKGROUND:
JS_ValueToInt32(cx, *vp, &i);
if(!JS_ValueToInt32(cx, *vp, &i))
return JS_FALSE;
rc=JS_SUSPENDREQUEST(cx);
textbackground(i);
JS_RESUMEREQUEST(cx, rc);
break;
case PROP_TEXTCOLOR:
JS_ValueToInt32(cx, *vp, &i);
if(!JS_ValueToInt32(cx, *vp, &i))
return JS_FALSE;
rc=JS_SUSPENDREQUEST(cx);
textcolor(i);
JS_RESUMEREQUEST(cx, rc);
......
......@@ -191,8 +191,10 @@ static JSBool js_console_set(JSContext *cx, JSObject *obj, jsid id, JSBool stric
JS_IdToValue(cx, id, &idval);
tiny = JSVAL_TO_INT(idval);
if(JSVAL_IS_NUMBER(*vp) || JSVAL_IS_BOOLEAN(*vp))
JS_ValueToInt32(cx, *vp, &val);
if(JSVAL_IS_NUMBER(*vp) || JSVAL_IS_BOOLEAN(*vp)) {
if(!JS_ValueToInt32(cx, *vp, &val))
return JS_FALSE;
}
switch(tiny) {
case CON_PROP_STATUS:
......@@ -402,10 +404,14 @@ js_inkey(JSContext *cx, uintN argc, jsval *arglist)
if((sbbs=(sbbs_t*)JS_GetContextPrivate(cx))==NULL)
return(JS_FALSE);
if(argc)
JS_ValueToInt32(cx,argv[0],&mode);
if(argc>1)
JS_ValueToInt32(cx,argv[1],&timeout);
if(argc) {
if(!JS_ValueToInt32(cx,argv[0],&mode))
return JS_FALSE;
}
if(argc>1) {
if(!JS_ValueToInt32(cx,argv[1],&timeout))
return JS_FALSE;
}
rc=JS_SUSPENDREQUEST(cx);
key[0]=sbbs->inkey(mode,timeout);
JS_RESUMEREQUEST(cx, rc);
......@@ -433,8 +439,10 @@ js_getkey(JSContext *cx, uintN argc, jsval *arglist)
if((sbbs=(sbbs_t*)JS_GetContextPrivate(cx))==NULL)
return(JS_FALSE);
if(argc)
JS_ValueToInt32(cx,argv[0],&mode);
if(argc) {
if(!JS_ValueToInt32(cx,argv[0],&mode))
return JS_FALSE;
}
rc=JS_SUSPENDREQUEST(cx);
key[0]=sbbs->getkey(mode);
JS_RESUMEREQUEST(cx, rc);
......@@ -471,8 +479,10 @@ js_handle_ctrlkey(JSContext *cx, uintN argc, jsval *arglist)
key=keystr[0];
}
if(argc>1)
JS_ValueToInt32(cx, argv[1], &mode);
if(argc>1) {
if(!JS_ValueToInt32(cx, argv[1], &mode))
return JS_FALSE;
}
rc=JS_SUSPENDREQUEST(cx);
JS_SET_RVAL(cx, arglist, BOOLEAN_TO_JSVAL(sbbs->handle_ctrlkey(key,mode)==0));
......@@ -499,10 +509,14 @@ js_getstr(JSContext *cx, uintN argc, jsval *arglist)
for(i=0;i<argc;i++) {
if(JSVAL_IS_NUMBER(argv[i])) {
if(!maxlen)
JS_ValueToInt32(cx,argv[i],(int32*)&maxlen);
else
JS_ValueToInt32(cx,argv[i],(int32*)&mode);
if(!maxlen) {
if(!JS_ValueToInt32(cx,argv[i],(int32*)&maxlen))
return JS_FALSE;
}
else {
if(!JS_ValueToInt32(cx,argv[i],(int32*)&mode))
return JS_FALSE;
}
continue;
}
if(JSVAL_IS_STRING(argv[i])) {
......@@ -551,10 +565,14 @@ js_getnum(JSContext *cx, uintN argc, jsval *arglist)
if((sbbs=(sbbs_t*)JS_GetContextPrivate(cx))==NULL)
return(JS_FALSE);
if(argc && JSVAL_IS_NUMBER(argv[0]))
JS_ValueToInt32(cx,argv[0],(int32*)&maxnum);
if(argc>1 && JSVAL_IS_NUMBER(argv[1]))
JS_ValueToInt32(cx,argv[1],(int32*)&dflt);
if(argc && JSVAL_IS_NUMBER(argv[0])) {
if(!JS_ValueToInt32(cx,argv[0],(int32*)&maxnum))
return JS_FALSE;
}
if(argc>1 && JSVAL_IS_NUMBER(argv[1])) {
if(!JS_ValueToInt32(cx,argv[1],(int32*)&dflt))
return JS_FALSE;
}
rc=JS_SUSPENDREQUEST(cx);
JS_SET_RVAL(cx, arglist, INT_TO_JSVAL(sbbs->getnum(maxnum,dflt)));
......@@ -582,7 +600,8 @@ js_getkeys(JSContext *cx, uintN argc, jsval *arglist)
for(i=0;i<argc;i++) {
if(JSVAL_IS_NUMBER(argv[i])) {
JS_ValueToInt32(cx,argv[i],(int32*)&maxnum);
if(!JS_ValueToInt32(cx,argv[i],(int32*)&maxnum))
return JS_FALSE;
continue;
}
if(JSVAL_IS_STRING(argv[i])) {
......@@ -637,8 +656,10 @@ js_gettemplate(JSContext *cx, uintN argc, jsval *arglist)
js_fmt = JS_ValueToString(cx, argv[i]);
else
js_str = JS_ValueToString(cx, argv[i]);
} else if(JSVAL_IS_NUMBER(argv[i]))
JS_ValueToInt32(cx,argv[i],(int32*)&mode);
} else if(JSVAL_IS_NUMBER(argv[i])) {
if(!JS_ValueToInt32(cx,argv[i],(int32*)&mode))
return JS_FALSE;
}
}
if(js_fmt==NULL)
......@@ -761,7 +782,7 @@ js_mnemonics(JSContext *cx, uintN argc, jsval *arglist)
return(JS_TRUE);
}
static void
static JSBool
js_set_attr(JSContext* cx, sbbs_t* sbbs, jsval val)
{
int32 attr;
......@@ -772,12 +793,15 @@ js_set_attr(JSContext* cx, sbbs_t* sbbs, jsval val)
JSVALUE_TO_STRING(cx, val, as, NULL);
attr=attrstr(as);
}
else
JS_ValueToInt32(cx, val, &attr);
else {
if(!JS_ValueToInt32(cx, val, &attr))
return JS_FALSE;;
}
rc=JS_SUSPENDREQUEST(cx);
sbbs->attr(attr);
JS_RESUMEREQUEST(cx, rc);
return JS_TRUE;
}
static JSBool
......@@ -792,8 +816,10 @@ js_clear(JSContext *cx, uintN argc, jsval *arglist)
if((sbbs=(sbbs_t*)JS_GetContextPrivate(cx))==NULL)
return(JS_FALSE);
if(argc)
js_set_attr(cx, sbbs, argv[0]);
if(argc) {
if(!js_set_attr(cx, sbbs, argv[0]))
return JS_FALSE;
}
rc=JS_SUSPENDREQUEST(cx);
sbbs->CLS;
......@@ -813,8 +839,10 @@ js_clearline(JSContext *cx, uintN argc, jsval *arglist)
if((sbbs=(sbbs_t*)JS_GetContextPrivate(cx))==NULL)
return(JS_FALSE);
if(argc)
js_set_attr(cx, sbbs, argv[0]);
if(argc) {
if(!js_set_attr(cx, sbbs, argv[0]))
return JS_FALSE;
}
rc=JS_SUSPENDREQUEST(cx);
sbbs->clearline();
......@@ -834,8 +862,10 @@ js_cleartoeol(JSContext *cx, uintN argc, jsval *arglist)
if((sbbs=(sbbs_t*)JS_GetContextPrivate(cx))==NULL)
return(JS_FALSE);
if(argc)
js_set_attr(cx, sbbs, argv[0]);
if(argc) {
if(!js_set_attr(cx, sbbs, argv[0]))
return JS_FALSE;
}
rc=JS_SUSPENDREQUEST(cx);
sbbs->cleartoeol();
......@@ -857,8 +887,10 @@ js_crlf(JSContext *cx, uintN argc, jsval *arglist)
if((sbbs=(sbbs_t*)JS_GetContextPrivate(cx))==NULL)
return(JS_FALSE);
if(argc)
JS_ValueToInt32(cx, argv[0], &count);
if(argc) {
if(!JS_ValueToInt32(cx, argv[0], &count))
return JS_FALSE;
}
rc=JS_SUSPENDREQUEST(cx);
for(i=0;i<count;i++) {
......@@ -900,8 +932,10 @@ js_beep(JSContext *cx, uintN argc, jsval *arglist)
if((sbbs=(sbbs_t*)JS_GetContextPrivate(cx))==NULL)
return(JS_FALSE);
if(argc)
JS_ValueToInt32(cx, argv[0], &count);
if(argc) {
if(!JS_ValueToInt32(cx, argv[0], &count))
return JS_FALSE;
}
rc=JS_SUSPENDREQUEST(cx);
for(i=0;i<count;i++)
sbbs->outchar('\a');
......@@ -1020,8 +1054,10 @@ js_putmsg(JSContext *cx, uintN argc, jsval *arglist)
if (!str)
return(JS_FALSE);
if(argc>1 && JSVAL_IS_NUMBER(argv[1]))
JS_ValueToInt32(cx,argv[1],(int32*)&mode);
if(argc>1 && JSVAL_IS_NUMBER(argv[1])) {
if(!JS_ValueToInt32(cx,argv[1],(int32*)&mode))
return JS_FALSE;
}
JSSTRING_TO_STRING(cx, str, cstr, NULL);
rc=JS_SUSPENDREQUEST(cx);
......@@ -1049,8 +1085,10 @@ js_printfile(JSContext *cx, uintN argc, jsval *arglist)
if (!str)
return(JS_FALSE);
if(argc>1 && JSVAL_IS_NUMBER(argv[1]))
JS_ValueToInt32(cx,argv[1],(int32*)&mode);
if(argc>1 && JSVAL_IS_NUMBER(argv[1])) {
if(!JS_ValueToInt32(cx,argv[1],(int32*)&mode))
return JS_FALSE;
}
JSSTRING_TO_STRING(cx, str, cstr, NULL);
rc=JS_SUSPENDREQUEST(cx);
......@@ -1078,10 +1116,14 @@ js_printtail(JSContext *cx, uintN argc, jsval *arglist)
for(i=0;i<argc;i++) {
if(JSVAL_IS_NUMBER(argv[i])) {
if(!lines)
JS_ValueToInt32(cx,argv[i],(int32*)&lines);
else
JS_ValueToInt32(cx,argv[i],(int32*)&mode);
if(!lines) {
if(!JS_ValueToInt32(cx,argv[i],(int32*)&lines))
return JS_FALSE;
}
else {
if(!JS_ValueToInt32(cx,argv[i],(int32*)&mode))
return JS_FALSE;
}
} else if(JSVAL_IS_STRING(argv[i]))
js_str = JS_ValueToString(cx, argv[i]);
}
......@@ -1150,7 +1192,8 @@ js_uselect(JSContext *cx, uintN argc, jsval *arglist)
for(i=0;i<argc;i++) {
if(JSVAL_IS_NUMBER(argv[i])) {
JS_ValueToInt32(cx,argv[i],&num);
if(!JS_ValueToInt32(cx,argv[i],&num))
return JS_FALSE;
continue;
}
if((js_str=JS_ValueToString(cx, argv[i]))==NULL)
......@@ -1252,13 +1295,16 @@ js_ansi(JSContext *cx, uintN argc, jsval *arglist)
if((sbbs=(sbbs_t*)JS_GetContextPrivate(cx))==NULL)
return(JS_FALSE);
if(argc)
JS_ValueToInt32(cx,argv[0],&attr);
if(argc) {
if(!JS_ValueToInt32(cx,argv[0],&attr))
return JS_FALSE;
}
if(argc>1) {
int32 curattr=0;
char buf[16];
JS_ValueToInt32(cx,argv[0],&curattr);
if(!JS_ValueToInt32(cx,argv[0],&curattr))
return JS_FALSE;
if((js_str=JS_NewStringCopyZ(cx,sbbs->ansi(attr,curattr,buf)))==NULL)
return(JS_FALSE);
} else {
......@@ -1320,12 +1366,15 @@ js_gotoxy(JSContext *cx, uintN argc, jsval *arglist)
if(JSVAL_IS_OBJECT(argv[0])) {
JS_GetProperty(cx, JSVAL_TO_OBJECT(argv[0]),"x", &val);
JS_ValueToInt32(cx,val,&x);
if(!JS_ValueToInt32(cx,val,&x))
return JS_FALSE;
JS_GetProperty(cx, JSVAL_TO_OBJECT(argv[0]),"y", &val);
JS_ValueToInt32(cx,val,&y);
if(!JS_ValueToInt32(cx,val,&y))
return JS_FALSE;
} else {
JS_ValueToInt32(cx,argv[0],&x);
JS_ValueToInt32(cx,argv[1],&y);
if((!JS_ValueToInt32(cx,argv[0],&x)) ||
(!JS_ValueToInt32(cx,argv[1],&y)))
return JS_FALSE;
}
rc=JS_SUSPENDREQUEST(cx);
......@@ -1395,8 +1444,10 @@ js_cursor_up(JSContext *cx, uintN argc, jsval *arglist)
if((sbbs=(sbbs_t*)JS_GetContextPrivate(cx))==NULL)
return(JS_FALSE);
if(argc)
JS_ValueToInt32(cx,argv[0],&val);
if(argc) {
if(!JS_ValueToInt32(cx,argv[0],&val))
return JS_FALSE;
}
rc=JS_SUSPENDREQUEST(cx);
sbbs->cursor_up(val);
JS_RESUMEREQUEST(cx, rc);
......@@ -1416,8 +1467,10 @@ js_cursor_down(JSContext *cx, uintN argc, jsval *arglist)
if((sbbs=(sbbs_t*)JS_GetContextPrivate(cx))==NULL)
return(JS_FALSE);
if(argc)
JS_ValueToInt32(cx,argv[0],&val);
if(argc) {
if(!JS_ValueToInt32(cx,argv[0],&val))
return JS_FALSE;
}
rc=JS_SUSPENDREQUEST(cx);
sbbs->cursor_down(val);
JS_RESUMEREQUEST(cx, rc);
......@@ -1437,8 +1490,10 @@ js_cursor_right(JSContext *cx, uintN argc, jsval *arglist)
if((sbbs=(sbbs_t*)JS_GetContextPrivate(cx))==NULL)
return(JS_FALSE);
if(argc)
JS_ValueToInt32(cx,argv[0],&val);
if(argc) {
if(!JS_ValueToInt32(cx,argv[0],&val))
return JS_FALSE;
}
rc=JS_SUSPENDREQUEST(cx);
sbbs->cursor_right(val);
JS_RESUMEREQUEST(cx, rc);
......@@ -1458,8 +1513,10 @@ js_cursor_left(JSContext *cx, uintN argc, jsval *arglist)
if((sbbs=(sbbs_t*)JS_GetContextPrivate(cx))==NULL)
return(JS_FALSE);
if(argc)
JS_ValueToInt32(cx,argv[0],&val);
if(argc) {
if(!JS_ValueToInt32(cx,argv[0],&val))
return JS_FALSE;
}
rc=JS_SUSPENDREQUEST(cx);
sbbs->cursor_left(val);
JS_RESUMEREQUEST(cx, rc);
......@@ -1556,9 +1613,12 @@ js_telnet_cmd(JSContext *cx, uintN argc, jsval *arglist)
if((sbbs=(sbbs_t*)JS_GetContextPrivate(cx))==NULL)
return(JS_FALSE);
JS_ValueToInt32(cx,argv[0],&cmd);
if(argc>1)
JS_ValueToInt32(cx,argv[1],&opt);
if(!JS_ValueToInt32(cx,argv[0],&cmd))
return JS_FALSE;
if(argc>1) {
if(!JS_ValueToInt32(cx,argv[1],&opt))
return JS_FALSE;
}
rc=JS_SUSPENDREQUEST(cx);
sbbs->send_telnet_cmd((uchar)cmd,(uchar)opt);
......
......@@ -515,8 +515,10 @@ js_mswait(JSContext *cx, uintN argc, jsval *arglist)
clock_t start=msclock();
jsrefcount rc;
if(argc)
JS_ValueToInt32(cx,argv[0],&val);
if(argc) {
if(!JS_ValueToInt32(cx,argv[0],&val))
return JS_FALSE;
}
rc=JS_SUSPENDREQUEST(cx);
mswait(val);
JS_RESUMEREQUEST(cx, rc);
......@@ -532,8 +534,10 @@ js_random(JSContext *cx, uintN argc, jsval *arglist)
jsval *argv=JS_ARGV(cx, arglist);
int32 val=100;
if(argc)
JS_ValueToInt32(cx,argv[0],&val);
if(argc) {
if(!JS_ValueToInt32(cx,argv[0],&val))
return JS_FALSE;
}
JS_SET_RVAL(cx, arglist,INT_TO_JSVAL(sbbs_random(val)));
return(JS_TRUE);
......@@ -557,10 +561,14 @@ js_beep(JSContext *cx, uintN argc, jsval *arglist)
JS_SET_RVAL(cx, arglist, JSVAL_VOID);
if(argc)
JS_ValueToInt32(cx,argv[0],&freq);
if(argc>1)
JS_ValueToInt32(cx,argv[1],&dur);
if(argc) {
if(!JS_ValueToInt32(cx,argv[0],&freq))
return JS_FALSE;
}
if(argc>1) {
if(!JS_ValueToInt32(cx,argv[1],&dur))
return JS_FALSE;
}
rc=JS_SUSPENDREQUEST(cx);
sbbs_beep(freq,dur);
......@@ -681,7 +689,8 @@ js_ascii(JSContext *cx, uintN argc, jsval *arglist)
}
/* ascii-int to str */
JS_ValueToInt32(cx,argv[0],&i);
if(!JS_ValueToInt32(cx,argv[0],&i))
return JS_FALSE;
str[0]=(uchar)i;
str[1]=0;
......@@ -714,7 +723,8 @@ js_ctrl(JSContext *cx, uintN argc, jsval *arglist)
return(JS_FALSE);
ch=*p;
} else {
JS_ValueToInt32(cx,argv[0],&i);
if(!JS_ValueToInt32(cx,argv[0],&i))
return JS_FALSE;
ch=(char)i;
}
......@@ -874,11 +884,15 @@ js_word_wrap(JSContext *cx, uintN argc, jsval *arglist)
if(inbuf==NULL)
return(JS_FALSE);
if(argc>1)
JS_ValueToInt32(cx,argv[1],&len);
if(argc>1) {
if(!JS_ValueToInt32(cx,argv[1],&len))
return JS_FALSE;
}
if(argc>2)
JS_ValueToInt32(cx,argv[2],&oldlen);
if(argc>2) {
if(!JS_ValueToInt32(cx,argv[2],&oldlen))
return JS_FALSE;
}
if(argc>3 && JSVAL_IS_BOOLEAN(argv[3]))
handle_quotes=JSVAL_TO_BOOLEAN(argv[3]);
......@@ -921,8 +935,10 @@ js_quote_msg(JSContext *cx, uintN argc, jsval *arglist)
if(inbuf==NULL)
return(JS_FALSE);
if(argc>1)
JS_ValueToInt32(cx,argv[1],&len);
if(argc>1) {
if(!JS_ValueToInt32(cx,argv[1],&len))