Commit d3fc4ad5aa for openssl.org

commit d3fc4ad5aab59ed525245ec704af3b04effc05eb
Author: Jakub Zelenka <jakub.zelenka@openssl.foundation>
Date:   Tue Apr 28 22:43:45 2026 +0200

    Check wrlmethod existence before sending alert

    If there is a memory failure during record wrlmethod allocation, then
    the alert is attemted but it crashes because wrlmethod is NULL.

    Found using memfail integration to fuzz tests: GH-30944

    Reviewed-by: Neil Horman <nhorman@openssl.org>
    Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
    Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
    Reviewed-by: Matt Caswell <matt@openssl.foundation>
    MergeDate: Fri May  1 12:09:11 2026
    (Merged from https://github.com/openssl/openssl/pull/31017)

diff --git a/ssl/statem/statem.c b/ssl/statem/statem.c
index a36f201989..04887bc9d1 100644
--- a/ssl/statem/statem.c
+++ b/ssl/statem/statem.c
@@ -152,7 +152,7 @@ void ossl_statem_send_fatal(SSL_CONNECTION *s, int al)
         return;
     ossl_statem_set_in_init(s, 1);
     s->statem.state = MSG_FLOW_ERROR;
-    if (al != SSL_AD_NO_ALERT)
+    if (al != SSL_AD_NO_ALERT && s->rlayer.wrlmethod != NULL)
         ssl3_send_alert(s, SSL3_AL_FATAL, al);
 }