Fix a record layer mem leak
authorMatt Caswell <matt@openssl.org>
Tue, 13 Sep 2022 17:01:18 +0000 (18:01 +0100)
committerMatt Caswell <matt@openssl.org>
Fri, 23 Sep 2022 13:54:49 +0000 (14:54 +0100)
Make sure we free the record layer before we free the connection BIOs

Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19198)

ssl/ssl_lib.c

index 35758df33bfc7b2e2d90fb76b0c9a8c5cdb0f0d0..440d1569759e24a6e7d14183f05f10f5043d6ade 100644 (file)
@@ -1361,13 +1361,13 @@ void ossl_ssl_connection_free(SSL *ssl)
     /* Ignore return value */
     ssl_free_wbio_buffer(s);
 
+    RECORD_LAYER_clear(&s->rlayer);
+
     BIO_free_all(s->wbio);
     s->wbio = NULL;
     BIO_free_all(s->rbio);
     s->rbio = NULL;
 
-    RECORD_LAYER_clear(&s->rlayer);
-
     BUF_MEM_free(s->init_buf);
 
     /* add extra stuff */