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 0fb9eb8d authored by deuce's avatar deuce
Browse files

Remove JS_GetSTringBytes() calls.

Only js_ValueToStringBytes() still leaks.
parent b855485d
......@@ -384,6 +384,7 @@ js_write(JSContext *cx, uintN argc, jsval *arglist)
JSString* str=NULL;
FILE* fp;
jsrefcount rc;
char *p;
JS_SET_RVAL(cx, arglist, JSVAL_VOID);
......@@ -394,8 +395,9 @@ js_write(JSContext *cx, uintN argc, jsval *arglist)
str = JS_ValueToString(cx, argv[i]);
if (!str)
return JS_FALSE;
JSSTRING_TO_STRING(cx, str, p);
rc=JS_SUSPENDREQUEST(cx);
fprintf(fp,"%s",JS_GetStringBytes(str));
fprintf(fp,"%s", p);
JS_RESUMEREQUEST(cx, rc);
}
......
......@@ -652,7 +652,7 @@ static JSBool js_bbs_set(JSContext *cx, JSObject *obj, jsid id, JSBool strict, j
else if(JSVAL_IS_STRING(*vp)) {
if((js_str = JS_ValueToString(cx, *vp))==NULL)
return(JS_FALSE);
p=JS_GetStringBytes(js_str);
JSSTRING_TO_STRING(cx, js_str, p);
}
switch(tiny) {
......@@ -922,7 +922,9 @@ static uint get_subnum(JSContext* cx, sbbs_t* sbbs, jsval val)
uint subnum=INVALID_SUB;
if(JSVAL_IS_STRING(val)) {
char* p=JS_GetStringBytes(JS_ValueToString(cx,val));
char * p;
JSSTRING_TO_STRING(cx, JSVAL_TO_STRING(val), p);
for(subnum=0;subnum<sbbs->cfg.total_subs;subnum++)
if(!stricmp(sbbs->cfg.sub[subnum]->code,p))
break;
......@@ -939,7 +941,8 @@ static uint get_dirnum(JSContext* cx, sbbs_t* sbbs, jsval val)
uint dirnum=INVALID_DIR;
if(JSVAL_IS_STRING(val)) {
char* p=JS_GetStringBytes(JS_ValueToString(cx,val));
char *p;
JSSTRING_TO_STRING(cx, JSVAL_TO_STRING(val), p);
for(dirnum=0;dirnum<sbbs->cfg.total_dirs;dirnum++)
if(!stricmp(sbbs->cfg.dir[dirnum]->code,p))
break;
......@@ -963,6 +966,7 @@ js_menu(JSContext *cx, uintN argc, jsval *arglist)
JSString* str;
sbbs_t* sbbs;
jsrefcount rc;
char *menu;
if((sbbs=(sbbs_t*)JS_GetContextPrivate(cx))==NULL)
return(JS_FALSE);
......@@ -972,7 +976,8 @@ js_menu(JSContext *cx, uintN argc, jsval *arglist)
return(JS_FALSE);
rc=JS_SUSPENDREQUEST(cx);
sbbs->menu(JS_GetStringBytes(str));
JSSTRING_TO_STRING(cx, str, menu);
sbbs->menu(menu);
JS_RESUMEREQUEST(cx, rc);
JS_SET_RVAL(cx, arglist, JSVAL_VOID);
......@@ -1051,9 +1056,9 @@ js_exec(JSContext *cx, uintN argc, jsval *arglist)
}
if(startup_dir!=NULL)
p_startup_dir=JS_GetStringBytes(startup_dir);
JSSTRING_TO_STRING(cx, startup_dir, p_startup_dir);
cstr=JS_GetStringBytes(cmd);
JSSTRING_TO_STRING(cx, cmd, cstr);
rc=JS_SUSPENDREQUEST(cx);
JS_SET_RVAL(cx, arglist, INT_TO_JSVAL(sbbs->external(cstr,mode,p_startup_dir)));
JS_RESUMEREQUEST(cx, rc);
......@@ -1078,10 +1083,8 @@ js_exec_xtrn(JSContext *cx, uintN argc, jsval *arglist)
return(JS_FALSE);
if(JSVAL_IS_STRING(argv[0])) {
if((str=JS_ValueToString(cx, argv[0]))==NULL)
return(JS_FALSE);
if((code=JS_GetStringBytes(str))==NULL)
JSVALUE_TO_STRING(cx,argv[0],code);
if(code==NULL)
return(JS_FALSE);
for(i=0;i<sbbs->cfg.total_xtrns;i++)
......@@ -1158,7 +1161,7 @@ js_chkpass(JSContext *cx, uintN argc, jsval *arglist)
JSString* str=JS_ValueToString(cx,argv[0]);
cstr=JS_GetStringBytes(str);
JSSTRING_TO_STRING(cx, str, cstr);
rc=JS_SUSPENDREQUEST(cx);
JS_SET_RVAL(cx, arglist, BOOLEAN_TO_JSVAL(sbbs->chkpass(cstr,&sbbs->useron,true)));
JS_RESUMEREQUEST(cx, rc);
......@@ -1221,10 +1224,8 @@ js_replace_text(JSContext *cx, uintN argc, jsval *arglist)
if(sbbs->text[i]!=sbbs->text_sav[i] && sbbs->text[i]!=nulstr)
free(sbbs->text[i]);
if((js_str=JS_ValueToString(cx, argv[1]))==NULL)
return(JS_TRUE);
if((p=JS_GetStringBytes(js_str))==NULL)
JSVALUE_TO_STRING(cx, argv[1], p);
if(p==NULL)
return(JS_TRUE);
len=strlen(p);
......@@ -1300,7 +1301,7 @@ js_load_text(JSContext *cx, uintN argc, jsval *arglist)
JS_SET_RVAL(cx, arglist, JSVAL_FALSE);
return(JS_TRUE);
}
cstr=JS_GetStringBytes(js_str);
JSSTRING_TO_STRING(cx, js_str, cstr);
rc=JS_SUSPENDREQUEST(cx);
for(i=0;i<TOTAL_TEXT;i++) {
......@@ -1362,7 +1363,7 @@ js_atcode(JSContext *cx, uintN argc, jsval *arglist)
if((sbbs=(sbbs_t*)JS_GetContextPrivate(cx))==NULL)
return(JS_FALSE);
instr = strdup(JS_GetStringBytes(JS_ValueToString(cx, argv[0])));
JSVALUE_TO_STRING(cx, argv[0], instr);
if(instr==NULL)
return(JS_FALSE);
......@@ -1382,7 +1383,6 @@ js_atcode(JSContext *cx, uintN argc, jsval *arglist)
rc=JS_SUSPENDREQUEST(cx);
cp=sbbs->atcode(instr,str2,sizeof(str2));
free(instr);
JS_RESUMEREQUEST(cx, rc);
if(cp==NULL)
JS_SET_RVAL(cx, arglist, JSVAL_NULL);
......@@ -1428,7 +1428,8 @@ js_logkey(JSContext *cx, uintN argc, jsval *arglist)
if(argc>1)
JS_ValueToBoolean(cx,argv[1],&comma);
if((p=JS_GetStringBytes(js_str))==NULL) {
JSSTRING_TO_STRING(cx, js_str, p);
if(p==NULL) {
JS_SET_RVAL(cx, arglist, JSVAL_FALSE);
return(JS_TRUE);
}
......@@ -1463,7 +1464,8 @@ js_logstr(JSContext *cx, uintN argc, jsval *arglist)
return(JS_TRUE);
}
if((p=JS_GetStringBytes(js_str))==NULL) {
JSSTRING_TO_STRING(cx, js_str, p);
if(p==NULL) {
JS_SET_RVAL(cx, arglist, JSVAL_FALSE);
return(JS_TRUE);
}
......@@ -1496,7 +1498,8 @@ js_finduser(JSContext *cx, uintN argc, jsval *arglist)
return(JS_TRUE);
}
if((p=JS_GetStringBytes(js_str))==NULL) {
JSSTRING_TO_STRING(cx, js_str, p);
if(p==NULL) {
JS_SET_RVAL(cx, arglist, INT_TO_JSVAL(0));
return(JS_TRUE);
}
......@@ -1534,12 +1537,14 @@ js_trashcan(JSContext *cx, uintN argc, jsval *arglist)
return(JS_TRUE);
}
if((can=JS_GetStringBytes(js_can))==NULL) {
JSSTRING_TO_STRING(cx, js_can, can);
if(can==NULL) {
JS_SET_RVAL(cx, arglist, JSVAL_FALSE);
return(JS_TRUE);
}
if((str=JS_GetStringBytes(js_str))==NULL) {
JSSTRING_TO_STRING(cx, js_str, str);
if(str==NULL) {
JS_SET_RVAL(cx, arglist, JSVAL_FALSE);
return(JS_TRUE);
}
......@@ -1611,10 +1616,12 @@ js_login(JSContext *cx, uintN argc, jsval *arglist)
if((js_pw=JS_ValueToString(cx, argv[1]))==NULL)
return(JS_FALSE);
if((name=JS_GetStringBytes(js_name))==NULL)
JSSTRING_TO_STRING(cx, js_name, name);
if(name==NULL)
return(JS_FALSE);
if((pw=JS_GetStringBytes(js_pw))==NULL)
JSSTRING_TO_STRING(cx, js_pw, pw);
if(pw==NULL)
return(JS_FALSE);
rc=JS_SUSPENDREQUEST(cx);
......@@ -1847,7 +1854,7 @@ js_batchaddlist(JSContext *cx, uintN argc, jsval *arglist)
if((sbbs=(sbbs_t*)JS_GetContextPrivate(cx))==NULL)
return(JS_FALSE);
cstr=JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
JSVALUE_TO_STRING(cx, argv[0], cstr);
rc=JS_SUSPENDREQUEST(cx);
sbbs->batch_add_list(cstr);
JS_RESUMEREQUEST(cx, rc);
......@@ -1874,7 +1881,7 @@ js_sendfile(JSContext *cx, uintN argc, jsval *arglist)
if(argc>1 && (p=js_ValueToStringBytes(cx, argv[1], NULL))!=NULL)
prot=*p;
cstr=JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
JSVALUE_TO_STRING(cx, argv[0], cstr);
rc=JS_SUSPENDREQUEST(cx);
JS_SET_RVAL(cx, arglist, BOOLEAN_TO_JSVAL(sbbs->sendfile(cstr,prot)));
JS_RESUMEREQUEST(cx, rc);
......@@ -1901,7 +1908,7 @@ js_recvfile(JSContext *cx, uintN argc, jsval *arglist)
if(argc>1 && (p=js_ValueToStringBytes(cx, argv[1], NULL))!=NULL)
prot=*p;
cstr=JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
JSVALUE_TO_STRING(cx, argv[0], cstr);
rc=JS_SUSPENDREQUEST(cx);
JS_SET_RVAL(cx, arglist, BOOLEAN_TO_JSVAL(sbbs->recvfile(cstr,prot)));
JS_RESUMEREQUEST(cx, rc);
......@@ -2306,8 +2313,8 @@ js_email(JSContext *cx, uintN argc, jsval *arglist)
jsval *argv=JS_ARGV(cx, arglist);
int32 usernumber=1;
int32 mode=WM_EMAIL;
const char* top="";
const char* subj="";
char* top=(char *)"";
char* subj=(char *)"";
JSString* js_top=NULL;
JSString* js_subj=NULL;
sbbs_t* sbbs;
......@@ -2330,9 +2337,9 @@ js_email(JSContext *cx, uintN argc, jsval *arglist)
}
if(js_top!=NULL)
top=JS_GetStringBytes(js_top);
JSSTRING_TO_STRING(cx, js_top, top);
if(js_subj!=NULL)
subj=JS_GetStringBytes(js_subj);
JSSTRING_TO_STRING(cx, js_subj, subj);
rc=JS_SUSPENDREQUEST(cx);
JS_SET_RVAL(cx, arglist, BOOLEAN_TO_JSVAL(sbbs->email(usernumber,top,subj,mode)));
......@@ -2345,7 +2352,7 @@ js_netmail(JSContext *cx, uintN argc, jsval *arglist)
JSObject *obj=JS_THIS_OBJECT(cx, arglist);
jsval *argv=JS_ARGV(cx, arglist);
int32 mode=0;
const char* subj="";
char* subj=(char *)"";
JSString* js_to;
JSString* js_subj=NULL;
sbbs_t* sbbs;
......@@ -2368,9 +2375,9 @@ js_netmail(JSContext *cx, uintN argc, jsval *arglist)
}
if(js_subj!=NULL)
subj=JS_GetStringBytes(js_subj);
JSSTRING_TO_STRING(cx, js_subj, subj);
cstr=JS_GetStringBytes(js_to);
JSSTRING_TO_STRING(cx, js_to, cstr);
rc=JS_SUSPENDREQUEST(cx);
JS_SET_RVAL(cx, arglist, BOOLEAN_TO_JSVAL(sbbs->netmail(cstr,subj,mode)));
JS_RESUMEREQUEST(cx, rc);
......@@ -2386,6 +2393,7 @@ js_bulkmail(JSContext *cx, uintN argc, jsval *arglist)
JSString* js_ars=NULL;
sbbs_t* sbbs;
jsrefcount rc;
char *p;
JS_SET_RVAL(cx, arglist, JSVAL_VOID);
......@@ -2393,10 +2401,10 @@ js_bulkmail(JSContext *cx, uintN argc, jsval *arglist)
return(JS_FALSE);
if(argc) {
if((js_ars=JS_ValueToString(cx, argv[0]))==NULL)
JSVALUE_TO_STRING(cx, argv[0], p);
if(p==NULL)
return(JS_FALSE);
ar=arstr(NULL,JS_GetStringBytes(js_ars), &sbbs->cfg);
ar=arstr(NULL, p, &sbbs->cfg);
}
rc=JS_SUSPENDREQUEST(cx);
sbbs->bulkmail(ar);
......@@ -2510,7 +2518,8 @@ js_telnet_gate(JSContext *cx, uintN argc, jsval *arglist)
if((js_addr=JS_ValueToString(cx, argv[0]))==NULL)
return(JS_FALSE);
if((addr=JS_GetStringBytes(js_addr))==NULL)
JSSTRING_TO_STRING(cx, js_addr, addr);
if(addr==NULL)
return(JS_FALSE);
if(argc>1 && JSVAL_IS_NUM(argv[1]))
......@@ -2673,7 +2682,8 @@ js_put_node_message(JSContext *cx, uintN argc, jsval *arglist)
if((js_msg=JS_ValueToString(cx, argv[1]))==NULL)
return(JS_FALSE);
if((msg=JS_GetStringBytes(js_msg))==NULL)
JSSTRING_TO_STRING(cx, js_msg, msg);
if(msg==NULL)
return(JS_FALSE);
rc=JS_SUSPENDREQUEST(cx);
......@@ -2732,7 +2742,8 @@ js_put_telegram(JSContext *cx, uintN argc, jsval *arglist)
if((js_msg=JS_ValueToString(cx, argv[1]))==NULL)
return(JS_FALSE);
if((msg=JS_GetStringBytes(js_msg))==NULL)
JSSTRING_TO_STRING(cx, js_msg, msg);
if(msg==NULL)
return(JS_FALSE);
rc=JS_SUSPENDREQUEST(cx);
......@@ -2748,8 +2759,8 @@ js_cmdstr(JSContext *cx, uintN argc, jsval *arglist)
JSObject *obj=JS_THIS_OBJECT(cx, arglist);
jsval *argv=JS_ARGV(cx, arglist);
char* p;
const char* fpath="";
const char* fspec="";
char* fpath=(char *)"";
char* fspec=(char *)"";
JSString* js_str;
sbbs_t* sbbs;
jsrefcount rc;
......@@ -2763,15 +2774,15 @@ js_cmdstr(JSContext *cx, uintN argc, jsval *arglist)
if (!js_str)
return(JS_FALSE);
p=JS_GetStringBytes(js_str);
JSSTRING_TO_STRING(cx, js_str, p);
for(uintN i=1;i<argc;i++) {
if(JSVAL_IS_STRING(argv[i])) {
js_str = JS_ValueToString(cx, argv[i]);
if(fpath==NULL)
fpath=JS_GetStringBytes(js_str);
JSSTRING_TO_STRING(cx, js_str, fpath) // Magic
else
fspec=JS_GetStringBytes(js_str);
JSSTRING_TO_STRING(cx, js_str, fspec);
}
}
......@@ -2821,7 +2832,7 @@ js_listfiles(JSContext *cx, uintN argc, jsval *arglist)
JSObject *obj=JS_THIS_OBJECT(cx, arglist);
jsval *argv=JS_ARGV(cx, arglist);
int32 mode=0;
const char* fspec=ALLFILES;
char* fspec=(char *)ALLFILES;
char buf[MAX_PATH+1];
uint dirnum;
JSString* js_str;
......@@ -2845,7 +2856,7 @@ js_listfiles(JSContext *cx, uintN argc, jsval *arglist)
JS_ValueToInt32(cx,argv[i],&mode);
else if(JSVAL_IS_STRING(argv[i])) {
js_str = JS_ValueToString(cx, argv[i]);
fspec=JS_GetStringBytes(js_str);
JSSTRING_TO_STRING(cx, js_str, fspec);
}
}
......@@ -2865,7 +2876,7 @@ js_listfileinfo(JSContext *cx, uintN argc, jsval *arglist)
JSObject *obj=JS_THIS_OBJECT(cx, arglist);
jsval *argv=JS_ARGV(cx, arglist);
int32 mode=FI_INFO;
const char* fspec=ALLFILES;
char* fspec=(char *)ALLFILES;
char buf[MAX_PATH+1];
uint dirnum;
JSString* js_str;
......@@ -2889,7 +2900,7 @@ js_listfileinfo(JSContext *cx, uintN argc, jsval *arglist)
JS_ValueToInt32(cx,argv[i],&mode);
else if(JSVAL_IS_STRING(argv[i])) {
js_str = JS_ValueToString(cx, argv[i]);
fspec=JS_GetStringBytes(js_str);
JSSTRING_TO_STRING(cx, js_str, fspec);
}
}
......@@ -3083,7 +3094,7 @@ js_scanposts(JSContext *cx, uintN argc, jsval *arglist)
{
JSObject *obj=JS_THIS_OBJECT(cx, arglist);
jsval *argv=JS_ARGV(cx, arglist);
const char* find="";
char* find=(char *)"";
int32 mode=0;
uint subnum;
sbbs_t* sbbs;
......@@ -3105,7 +3116,7 @@ js_scanposts(JSContext *cx, uintN argc, jsval *arglist)
if(JSVAL_IS_NUM(argv[i]))
JS_ValueToInt32(cx,argv[i],&mode);
else if(JSVAL_IS_STRING(argv[i]))
find=JS_GetStringBytes(JS_ValueToString(cx,argv[i]));
JSVALUE_TO_STRING(cx, argv[i], find);
}
if(*find)
......@@ -3122,7 +3133,7 @@ js_listmsgs(JSContext *cx, uintN argc, jsval *arglist)
{
JSObject *obj=JS_THIS_OBJECT(cx, arglist);
jsval *argv=JS_ARGV(cx, arglist);
const char* find="";
char* find=(char *)"";
int32 mode=0;
int32 start=0;
uint subnum;
......@@ -3147,7 +3158,7 @@ js_listmsgs(JSContext *cx, uintN argc, jsval *arglist)
if(JSVAL_IS_NUM(argv[argn]))
JS_ValueToInt32(cx,argv[argn++],&start);
if(JSVAL_IS_STRING(argv[argn]))
find=JS_GetStringBytes(JS_ValueToString(cx,argv[argn++]));
JSVALUE_TO_STRING(cx, argv[argn++], find);
rc=JS_SUSPENDREQUEST(cx);
JS_SET_RVAL(cx, arglist, INT_TO_JSVAL(sbbs->listsub(subnum,mode,start,find)));
......@@ -3249,17 +3260,19 @@ js_chk_ar(JSContext *cx, uintN argc, jsval *arglist)
JSString* js_str;
sbbs_t* sbbs;
jsrefcount rc;
char *p;
JS_SET_RVAL(cx, arglist, JSVAL_VOID);
if((sbbs=(sbbs_t*)JS_GetContextPrivate(cx))==NULL)
return JS_FALSE;
if((js_str=JS_ValueToString(cx, argv[0]))==NULL)
JSVALUE_TO_STRING(cx, argv[0], p);
if(p==NULL)
return JS_FALSE;
rc=JS_SUSPENDREQUEST(cx);
ar = arstr(NULL,JS_GetStringBytes(js_str),&sbbs->cfg);
ar = arstr(NULL,p,&sbbs->cfg);
JS_SET_RVAL(cx, arglist, BOOLEAN_TO_JSVAL(sbbs->chk_ar(ar,&sbbs->useron,&sbbs->client)));
......@@ -3647,7 +3660,7 @@ static JSBool js_bbs_resolve(JSContext *cx, JSObject *obj, jsid id)
jsval idval;
JS_IdToValue(cx, id, &idval);
name=JS_GetStringBytes(JSVAL_TO_STRING(idval));
JSSTRING_TO_STRING(cx, JSVAL_TO_STRING(idval), name);
}
return(js_SyncResolve(cx, obj, name, js_bbs_properties, js_bbs_functions, NULL, 0));
......
......@@ -138,7 +138,7 @@ static JSBool js_client_resolve(JSContext *cx, JSObject *obj, jsid id)
jsval idval;
JS_IdToValue(cx, id, &idval);
name=JS_GetStringBytes(JSVAL_TO_STRING(idval));
JSSTRING_TO_STRING(cx, JSVAL_TO_STRING(idval), name);
}
return(js_SyncResolve(cx, obj, name, js_client_properties, NULL, NULL, 0));
......
......@@ -187,8 +187,7 @@ js_send(JSContext *cx, uintN argc, jsval *arglist)
JS_SET_RVAL(cx, arglist, JSVAL_FALSE);
str = JS_ValueToString(cx, argv[0]);
cp = JS_GetStringBytes(str);
JSVALUE_TO_STRING(cx, argv[0], cp);
len = JS_GetStringLength(str);
rc=JS_SUSPENDREQUEST(cx);
......@@ -226,8 +225,8 @@ js_sendfile(JSContext *cx, uintN argc, jsval *arglist)
JS_SET_RVAL(cx, arglist, JSVAL_FALSE);
if((str = JS_ValueToString(cx, argv[0]))==NULL
|| (fname=JS_GetStringBytes(str))==NULL) {
JSVALUE_TO_STRING(cx, argv[0], fname);
if(fname==NULL) {
JS_ReportError(cx,"Failure reading filename");
return(JS_FALSE);
}
......@@ -733,7 +732,7 @@ static JSBool js_com_resolve(JSContext *cx, JSObject *obj, jsid id)
jsval idval;
JS_IdToValue(cx, id, &idval);
name=JS_GetStringBytes(JSVAL_TO_STRING(idval));
JSSTRING_TO_STRING(cx, JSVAL_TO_STRING(idval), name);
}
return(js_SyncResolve(cx, obj, name, js_com_properties, js_com_functions, NULL, 0));
......@@ -771,8 +770,9 @@ js_com_constructor(JSContext *cx, uintN argc, jsval *arglist)
obj=JS_NewObject(cx, &js_com_class, NULL, NULL);
JS_SET_RVAL(cx, arglist, OBJECT_TO_JSVAL(obj));
if(argc==0 || (str = JS_ValueToString(cx, argv[0]))==NULL
|| (fname=JS_GetStringBytes(str))==NULL) {
if(argc > 0)
JSVALUE_TO_STRING(cx, argv[0], fname);
if(argc==0 || fname==NULL) {
JS_ReportError(cx,"Failure reading port name");
return(JS_FALSE);
}
......
......@@ -1134,7 +1134,7 @@ static JSBool js_conio_resolve(JSContext *cx, JSObject *obj, jsid id)
jsval idval;
JS_IdToValue(cx, id, &idval);
name=JS_GetStringBytes(JSVAL_TO_STRING(idval));
JSSTRING_TO_STRING(cx, JSVAL_TO_STRING(idval), name);
}
return(js_SyncResolve(cx, obj, name, js_properties, js_functions, NULL, 0));
......
......@@ -183,6 +183,7 @@ static JSBool js_console_set(JSContext *cx, JSObject *obj, jsid id, JSBool stric
sbbs_t* sbbs;
JSString* str;
jsrefcount rc;
char *sval;
if((sbbs=(sbbs_t*)JS_GetContextPrivate(cx))==NULL)
return(JS_FALSE);
......@@ -205,9 +206,10 @@ static JSBool js_console_set(JSContext *cx, JSObject *obj, jsid id, JSBool stric
break;
case CON_PROP_ATTR:
if(JSVAL_IS_STRING(*vp)) {
if((str=JS_ValueToString(cx, *vp))==NULL)
JSVALUE_TO_STRING(cx, *vp, sval);
if(sval==NULL)
break;
val=attrstr(JS_GetStringBytes(str));
val=attrstr(sval);
}
rc=JS_SUSPENDREQUEST(cx);
sbbs->attr(val);
......@@ -226,9 +228,10 @@ static JSBool js_console_set(JSContext *cx, JSObject *obj, jsid id, JSBool stric
sbbs->autoterm=val;
break;
case CON_PROP_TERMINAL:
if((str=JS_ValueToString(cx, *vp))==NULL)
JSVALUE_TO_STRING(cx, *vp, sval);
if(sval==NULL)
break;
SAFECOPY(sbbs->terminal,JS_GetStringBytes(str));
SAFECOPY(sbbs->terminal,sval);
break;
case CON_PROP_INACTIV_WARN:
sbbs->cfg.sec_warn = (uint16_t)val;
......@@ -259,9 +262,10 @@ static JSBool js_console_set(JSContext *cx, JSObject *obj, jsid id, JSBool stric
sbbs->getstr_offset=val;
break;
case CON_PROP_QUESTION:
if((str=JS_ValueToString(cx, *vp))==NULL)
JSVALUE_TO_STRING(cx, *vp, sval);
if(sval==NULL)
break;
SAFECOPY(sbbs->question,JS_GetStringBytes(str));
SAFECOPY(sbbs->question,sval);
break;
case CON_PROP_CTRLKEY_PASSTHRU:
if(JSVAL_IS_STRING(*vp)) {
......@@ -273,7 +277,8 @@ static JSBool js_console_set(JSContext *cx, JSObject *obj, jsid id, JSBool stric
if((str=JS_ValueToString(cx, *vp))==NULL)
break;
val=sbbs->cfg.ctrlkey_passthru;
for(s=JS_GetStringBytes(str); *s; s++) {
JSSTRING_TO_STRING(cx, str, s);
for(; *s; s++) {
if(*s=='+')
op=1;
else if(*s=='-')
......@@ -454,6 +459,7 @@ js_handle_ctrlkey(JSContext *cx, uintN argc, jsval *arglist)
sbbs_t* sbbs;
JSString* js_str;
jsrefcount rc;
char *keystr;
JS_SET_RVAL(cx, arglist, JSVAL_FALSE);
......@@ -463,9 +469,10 @@ js_handle_ctrlkey(JSContext *cx, uintN argc, jsval *arglist)
if(JSVAL_IS_INT(argv[0]))
key=(char)JSVAL_TO_INT(argv[0]);
else {
if((js_str=JS_ValueToString(cx, argv[0]))==NULL)
JSVALUE_TO_STRING(cx, argv[0], keystr);
if(keystr==NULL)
return(JS_FALSE);
key=*JS_GetStringBytes(js_str);
key=keystr[0];
}
if(argc>1)
......@@ -482,7 +489,7 @@ js_getstr(JSContext *cx, uintN argc, jsval *arglist)
{
JSObject *obj=JS_THIS_OBJECT(cx, arglist);
jsval *argv=JS_ARGV(cx, arglist);
char *p;
char *p,*p2;
long mode=0;
uintN i;
size_t maxlen=0;
......@@ -515,8 +522,10 @@ js_getstr(JSContext *cx, uintN argc, jsval *arglist)
if((p=(char *)calloc(1,maxlen+1))==NULL)
return(JS_FALSE);
if(js_str!=NULL)
sprintf(p,"%.*s",(int)maxlen,JS_GetStringBytes(js_str));
if(js_str!=NULL) {
JSSTRING_TO_STRING(cx, js_str, p2);
sprintf(p,"%.*s",(int)maxlen,p2);
}
rc=JS_SUSPENDREQUEST(cx);
sbbs->getstr(p,maxlen,mode);
......@@ -590,7 +599,7 @@ js_getkeys(JSContext *cx, uintN argc, jsval *arglist)
if(js_str==NULL)
return(JS_FALSE);
cstr=JS_GetStringBytes(js_str);
JSSTRING_TO_STRING(cx, js_str, cstr);
rc=JS_SUSPENDREQUEST(cx);
val=sbbs->getkeys(cstr,maxnum);
JS_RESUMEREQUEST(cx, rc);
......@@ -645,10 +654,12 @@ js_gettemplate(JSContext *cx, uintN argc, jsval *arglist)
if(js_str==NULL)
str[0]=0;