diff --git a/src/dtls13.c b/src/dtls13.c index 2b9d1edaa..90ba294ee 100644 --- a/src/dtls13.c +++ b/src/dtls13.c @@ -811,7 +811,7 @@ static int Dtls13SendOneFragmentRtx(WOLFSSL* ssl, enum HandShakeType handshakeType, word16 outputSize, byte* message, word32 length, int hashOutput) { - Dtls13RtxRecord* rtxRecord; + Dtls13RtxRecord* rtxRecord = NULL; word16 recordHeaderLength; byte isProtected; int ret; @@ -819,20 +819,23 @@ static int Dtls13SendOneFragmentRtx(WOLFSSL* ssl, isProtected = Dtls13TypeIsEncrypted(handshakeType); recordHeaderLength = Dtls13GetRlHeaderLength(ssl, isProtected); - rtxRecord = Dtls13RtxNewRecord(ssl, message + recordHeaderLength, - (word16)(length - recordHeaderLength), handshakeType, - ssl->dtls13EncryptEpoch->nextSeqNumber); - - if (rtxRecord == NULL) - return MEMORY_E; + if (handshakeType != hello_retry_request) { + rtxRecord = Dtls13RtxNewRecord(ssl, message + recordHeaderLength, + (word16)(length - recordHeaderLength), handshakeType, + ssl->dtls13EncryptEpoch->nextSeqNumber); + if (rtxRecord == NULL) + return MEMORY_E; + } ret = Dtls13SendFragment(ssl, message, outputSize, (word16)length, handshakeType, hashOutput, Dtls13SendNow(ssl, handshakeType)); - if (ret == 0 || ret == WANT_WRITE) - Dtls13RtxAddRecord(&ssl->dtls13Rtx, rtxRecord); - else - Dtls13FreeRtxBufferRecord(ssl, rtxRecord); + if (rtxRecord != NULL) { + if (ret == 0 || ret == WANT_WRITE) + Dtls13RtxAddRecord(&ssl->dtls13Rtx, rtxRecord); + else + Dtls13FreeRtxBufferRecord(ssl, rtxRecord); + } return ret; }