Skip to content

Commit 4d2d47c

Browse files
authored
chore: fix possible null pointer dereference found by Coverity (openresty#1845)
1 parent 23e40f3 commit 4d2d47c

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/ngx_http_lua_ssl_session_storeby.c

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

329329
c = log->data;
330330

331-
if (c->addr_text.len) {
332-
p = ngx_snprintf(buf, len, ", client: %V", &c->addr_text);
333-
len -= p - buf;
334-
buf = p;
335-
}
331+
if (c != NULL) {
332+
if (c->addr_text.len) {
333+
p = ngx_snprintf(buf, len, ", client: %V", &c->addr_text);
334+
len -= p - buf;
335+
buf = p;
336+
}
336337

337-
if (c && c->listening && c->listening->addr_text.len) {
338-
p = ngx_snprintf(buf, len, ", server: %V", &c->listening->addr_text);
339-
buf = p;
338+
if (c->listening && c->listening->addr_text.len) {
339+
p = ngx_snprintf(buf, len, ", server: %V", \
340+
&c->listening->addr_text);
341+
buf = p;
342+
}
340343
}
341344

342345
return buf;

0 commit comments

Comments
 (0)