Skip to content
Snippets Groups Projects
Commit 8b898fde authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Fix dead code issues reported by Coverity-scan

parent 4d23eff9
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
...@@ -1227,32 +1227,20 @@ js_spamlog(JSContext *cx, uintN argc, jsval *arglist) ...@@ -1227,32 +1227,20 @@ js_spamlog(JSContext *cx, uintN argc, jsval *arglist)
if((sys = (js_system_private_t*)js_GetClassPrivate(cx,obj,&js_system_class))==NULL) if((sys = (js_system_private_t*)js_GetClassPrivate(cx,obj,&js_system_class))==NULL)
return JS_FALSE; return JS_FALSE;
for(i=0;i<argc;i++) { for(i=0;i<argc && from == NULL;i++) {
if(!JSVAL_IS_STRING(argv[i])) if(!JSVAL_IS_STRING(argv[i]))
continue; continue;
if(from==NULL) {
JSVALUE_TO_MSTRING(cx, argv[i], p, NULL); JSVALUE_TO_MSTRING(cx, argv[i], p, NULL);
if(JS_IsExceptionPending(cx)) { if(p == NULL || JS_IsExceptionPending(cx)) {
if(prot)
free(prot); free(prot);
if(action)
free(action); free(action);
if(reason)
free(reason); free(reason);
if(host)
free(host); free(host);
if(ip_addr)
free(ip_addr); free(ip_addr);
if(to)
free(to); free(to);
if(from)
free(from);
if(p)
free(p); free(p);
return JS_FALSE; return JS_FALSE;
} }
if(p==NULL)
continue;
if(prot==NULL) if(prot==NULL)
prot=p; prot=p;
else if(action==NULL) else if(action==NULL)
...@@ -1265,27 +1253,17 @@ js_spamlog(JSContext *cx, uintN argc, jsval *arglist) ...@@ -1265,27 +1253,17 @@ js_spamlog(JSContext *cx, uintN argc, jsval *arglist)
ip_addr=p; ip_addr=p;
else if(to==NULL) else if(to==NULL)
to=p; to=p;
else if(from==NULL)
from=p;
else else
free(p); from=p;
}
} }
rc=JS_SUSPENDREQUEST(cx); rc=JS_SUSPENDREQUEST(cx);
ret=spamlog(sys->cfg,prot,action,reason,host,ip_addr,to,from); ret=spamlog(sys->cfg,prot,action,reason,host,ip_addr,to,from);
if(prot)
free(prot); free(prot);
if(action)
free(action); free(action);
if(reason)
free(reason); free(reason);
if(host)
free(host); free(host);
if(ip_addr)
free(ip_addr); free(ip_addr);
if(to)
free(to); free(to);
if(from)
free(from); free(from);
JS_RESUMEREQUEST(cx, rc); JS_RESUMEREQUEST(cx, rc);
JS_SET_RVAL(cx, arglist, BOOLEAN_TO_JSVAL(ret)); JS_SET_RVAL(cx, arglist, BOOLEAN_TO_JSVAL(ret));
...@@ -1328,40 +1306,28 @@ js_hacklog(JSContext *cx, uintN argc, jsval *arglist) ...@@ -1328,40 +1306,28 @@ js_hacklog(JSContext *cx, uintN argc, jsval *arglist)
continue; continue;
if(host==NULL) { if(host==NULL) {
JSVALUE_TO_MSTRING(cx, argv[i], p, NULL); JSVALUE_TO_MSTRING(cx, argv[i], p, NULL);
if(JS_IsExceptionPending(cx)) { if(JS_IsExceptionPending(cx) || p == NULL) {
if(prot)
free(prot); free(prot);
if(user)
free(user); free(user);
if(text)
free(text); free(text);
if(host)
free(host);
if(p)
free(p); free(p);
return JS_FALSE; return JS_FALSE;
} }
}
if(p==NULL)
continue;
if(prot==NULL) if(prot==NULL)
prot=p; prot=p;
else if(user==NULL) else if(user==NULL)
user=p; user=p;
else if(text==NULL) else if(text==NULL)
text=p; text=p;
else if(host==NULL) else
host=p; host=p;
} }
}
rc=JS_SUSPENDREQUEST(cx); rc=JS_SUSPENDREQUEST(cx);
ret=hacklog(sys->cfg,prot,user,text,host,&addr); ret=hacklog(sys->cfg,prot,user,text,host,&addr);
if(prot)
free(prot); free(prot);
if(user)
free(user); free(user);
if(text)
free(text); free(text);
if(host)
free(host); free(host);
JS_RESUMEREQUEST(cx, rc); JS_RESUMEREQUEST(cx, rc);
JS_SET_RVAL(cx, arglist, BOOLEAN_TO_JSVAL(ret)); JS_SET_RVAL(cx, arglist, BOOLEAN_TO_JSVAL(ret));
...@@ -1390,31 +1356,19 @@ js_filter_ip(JSContext *cx, uintN argc, jsval *arglist) ...@@ -1390,31 +1356,19 @@ js_filter_ip(JSContext *cx, uintN argc, jsval *arglist)
if((sys = (js_system_private_t*)js_GetClassPrivate(cx,obj,&js_system_class))==NULL) if((sys = (js_system_private_t*)js_GetClassPrivate(cx,obj,&js_system_class))==NULL)
return JS_FALSE; return JS_FALSE;
for(i=0;i<argc;i++) { for(i=0; i<argc && fname == NULL; i++) {
if(!JSVAL_IS_STRING(argv[i])) if(!JSVAL_IS_STRING(argv[i]))
continue; continue;
if(fname==NULL) {
JSVALUE_TO_MSTRING(cx, argv[i], p, NULL); JSVALUE_TO_MSTRING(cx, argv[i], p, NULL);
if(JS_IsExceptionPending(cx)) { if(JS_IsExceptionPending(cx) || p == NULL) {
if(prot)
free(prot); free(prot);
if(reason)
free(reason); free(reason);
if(host)
free(host); free(host);
if(ip_addr)
free(ip_addr); free(ip_addr);
if(from)
free(from); free(from);
if(fname)
free(fname);
if(p)
free(p); free(p);
return JS_FALSE; return JS_FALSE;
} }
}
if(p==NULL)
continue;
if(prot==NULL) if(prot==NULL)
prot=p; prot=p;
else if(reason==NULL) else if(reason==NULL)
...@@ -1425,22 +1379,16 @@ js_filter_ip(JSContext *cx, uintN argc, jsval *arglist) ...@@ -1425,22 +1379,16 @@ js_filter_ip(JSContext *cx, uintN argc, jsval *arglist)
ip_addr=p; ip_addr=p;
else if(from==NULL) else if(from==NULL)
from=p; from=p;
else if(fname==NULL) else
fname=p; fname=p;
} }
rc=JS_SUSPENDREQUEST(cx); rc=JS_SUSPENDREQUEST(cx);
ret=filter_ip(sys->cfg,prot,reason,host,ip_addr,from,fname); ret=filter_ip(sys->cfg,prot,reason,host,ip_addr,from,fname);
if(prot)
free(prot); free(prot);
if(reason)
free(reason); free(reason);
if(host)
free(host); free(host);
if(ip_addr)
free(ip_addr); free(ip_addr);
if(from)
free(from); free(from);
if(fname)
free(fname); free(fname);
JS_RESUMEREQUEST(cx, rc); JS_RESUMEREQUEST(cx, rc);
JS_SET_RVAL(cx, arglist, BOOLEAN_TO_JSVAL(ret)); JS_SET_RVAL(cx, arglist, BOOLEAN_TO_JSVAL(ret));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment