Skip to content

Commit ebf5a4a

Browse files
committed
src/ngx_http_lua_timer.c: fix possible null pointer dereference found by Coverity
734 buf = p; 735 deref_ptr: Directly dereferencing pointer c. 736 if (c->addr_text.len) { 737 p = ngx_snprintf(buf, len, ", client: %V", &c->addr_text); 738 len -= p - buf; 739 buf = p; 740 } 741 CID 149839 (openresty#1 of 1): Dereference before null check (REVERSE_INULL)check_after_deref: Null-checking c suggests that it may be null, but it has already been dereferenced on all paths leading to the check. 742 if (c && c->listening && c->listening->addr_text.len) { 743 p = ngx_snprintf(buf, len, ", server: %V", &c->listening->addr_text); 744 /* len -= p - buf; */ 745 buf = p; 746 }
1 parent 9a3176e commit ebf5a4a

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

src/ngx_http_lua_timer.c

+12-9
Original file line numberDiff line numberDiff line change
@@ -733,16 +733,19 @@ ngx_http_lua_log_timer_error(ngx_log_t *log, u_char *buf, size_t len)
733733
len -= p - buf;
734734
buf = p;
735735

736-
if (c->addr_text.len) {
737-
p = ngx_snprintf(buf, len, ", client: %V", &c->addr_text);
738-
len -= p - buf;
739-
buf = p;
740-
}
736+
if (c != NULL) {
737+
if (c->addr_text.len) {
738+
p = ngx_snprintf(buf, len, ", client: %V", &c->addr_text);
739+
len -= p - buf;
740+
buf = p;
741+
}
741742

742-
if (c && c->listening && c->listening->addr_text.len) {
743-
p = ngx_snprintf(buf, len, ", server: %V", &c->listening->addr_text);
744-
/* len -= p - buf; */
745-
buf = p;
743+
if (c->listening && c->listening->addr_text.len) {
744+
p = ngx_snprintf(buf, len, ", server: %V",
745+
&c->listening->addr_text);
746+
/* len -= p - buf; */
747+
buf = p;
748+
}
746749
}
747750

748751
return buf;

0 commit comments

Comments
 (0)