Skip to content

Commit 9a3176e

Browse files
authored
chore: fix possible null pointer dereference found by Coverity (openresty#1844)
1 parent 4d2d47c commit 9a3176e

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/ngx_http_lua_ssl_session_fetchby.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -442,15 +442,18 @@ ngx_http_lua_log_ssl_sess_fetch_error(ngx_log_t *log, u_char *buf, size_t len)
442442

443443
c = log->data;
444444

445-
if (c->addr_text.len) {
446-
p = ngx_snprintf(buf, len, ", client: %V", &c->addr_text);
447-
len -= p - buf;
448-
buf = p;
449-
}
445+
if (c != NULL) {
446+
if (c->addr_text.len) {
447+
p = ngx_snprintf(buf, len, ", client: %V", &c->addr_text);
448+
len -= p - buf;
449+
buf = p;
450+
}
450451

451-
if (c && c->listening && c->listening->addr_text.len) {
452-
p = ngx_snprintf(buf, len, ", server: %V", &c->listening->addr_text);
453-
buf = p;
452+
if (c->listening && c->listening->addr_text.len) {
453+
p = ngx_snprintf(buf, len, ", server: %V", \
454+
&c->listening->addr_text);
455+
buf = p;
456+
}
454457
}
455458

456459
return buf;

0 commit comments

Comments
 (0)