Mail: fix session cleanup on error path

Previously, when ngx_handle_read_event() or ngx_handle_write_event()
returned an error while handling an SMTP, POP3 or IMAP session, the
released session memory could be accessed after handling the error.
This commit is contained in:
Roman Arutyunyan authored and Roman Arutyunyan committed 2026-05-15 16:25:01 +04:00
1 parent 58a7bc3406
commit a4d5da3e40
4 files changed
+4

No files matched your search

+1
View File
@@ -48,6 +48,7 @@ ngx_mail_imap_init_session(ngx_mail_session_t *s, ngx_connection_t *c)
if (ngx_handle_read_event(c->read, 0) != NGX_OK) {
ngx_mail_close_connection(c);
return;
}
ngx_mail_send(c->write);
+1
View File
@@ -69,6 +69,7 @@ ngx_mail_pop3_init_session(ngx_mail_session_t *s, ngx_connection_t *c)
if (ngx_handle_read_event(c->read, 0) != NGX_OK) {
ngx_mail_close_connection(c);
return;
}
ngx_mail_send(c->write);
+1
View File
@@ -894,6 +894,7 @@ ngx_mail_proxy_write_handler(ngx_event_t *wev)
if (ngx_handle_write_event(wev, 0) != NGX_OK) {
ngx_mail_proxy_internal_server_error(s);
return;
}
if (c->read->ready) {
+1
View File
@@ -340,6 +340,7 @@ ngx_mail_smtp_greeting(ngx_mail_session_t *s, ngx_connection_t *c)
if (ngx_handle_read_event(c->read, 0) != NGX_OK) {
ngx_mail_close_connection(c);
return;
}
if (c->read->ready) {