X-Git-Url: https://git.openssl.org/?p=openssl.git;a=blobdiff_plain;f=ssl%2Frecord%2Frec_layer_s3.c;fp=ssl%2Frecord%2Frec_layer_s3.c;h=dc0b8b3d9efe4e11424ee45697607bf057aae787;hp=9a4cd853894abac46bcb9d566f27f71f737ee3e6;hb=20c7febc860ae8e67f52912ee205d2e324e7beed;hpb=22094d11a780f7485f0929ccfac806e0d02f82a9 diff --git a/ssl/record/rec_layer_s3.c b/ssl/record/rec_layer_s3.c index 9a4cd85389..dc0b8b3d9e 100644 --- a/ssl/record/rec_layer_s3.c +++ b/ssl/record/rec_layer_s3.c @@ -1356,11 +1356,14 @@ int ssl_set_new_record_layer(SSL_CONNECTION *s, int version, /* * Free the old record layer if we have one except in the case of DTLS when - * writing. In that case the record layer is still referenced by buffered - * messages for potential retransmit. Only when those buffered messages get - * freed do we free the record layer object (see dtls1_hm_fragment_free) + * writing and there are still buffered sent messages in our queue. In that + * case the record layer is still referenced by those buffered messages for + * potential retransmit. Only when those buffered messages get freed do we + * free the record layer object (see dtls1_hm_fragment_free) */ - if (!SSL_CONNECTION_IS_DTLS(s) || direction == OSSL_RECORD_DIRECTION_READ) { + if (!SSL_CONNECTION_IS_DTLS(s) + || direction == OSSL_RECORD_DIRECTION_READ + || pqueue_peek(s->d1->sent_messages) == NULL) { if (*thismethod != NULL && !(*thismethod)->free(*thisrl)) { SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR); return 0;