@@ -1547,6 +1547,8 @@ void FreeWriteDup(WOLFSSL* ssl)
15471547*/
15481548static int DupSSL(WOLFSSL* dup, WOLFSSL* ssl)
15491549{
1550+ word16 tmp_weOwnRng;
1551+
15501552 /* shared dupWrite setup */
15511553 ssl->dupWrite = (WriteDup*)XMALLOC(sizeof(WriteDup), ssl->heap,
15521554 DYNAMIC_TYPE_WRITEDUP);
@@ -1563,12 +1565,7 @@ static int DupSSL(WOLFSSL* dup, WOLFSSL* ssl)
15631565 ssl->dupWrite->dupCount = 2; /* both sides have a count to start */
15641566 dup->dupWrite = ssl->dupWrite; /* each side uses */
15651567
1566- if (dup->options.weOwnRng) {
1567- wc_FreeRng(dup->rng);
1568- XFREE(dup->rng, dup->heap, DYNAMIC_TYPE_RNG);
1569- dup->rng = NULL;
1570- dup->options.weOwnRng = 0;
1571- }
1568+ tmp_weOwnRng = dup->options.weOwnRng;
15721569
15731570 /* copy write parts over to dup writer */
15741571 XMEMCPY(&dup->specs, &ssl->specs, sizeof(CipherSpecs));
@@ -1595,6 +1592,9 @@ static int DupSSL(WOLFSSL* dup, WOLFSSL* ssl)
15951592 dup->truncated_hmac = ssl->truncated_hmac;
15961593#endif
15971594
1595+ /* Restore rng option */
1596+ dup->options.weOwnRng = tmp_weOwnRng;
1597+
15981598 /* unique side dup setup */
15991599 dup->dupSide = WRITE_DUP_SIDE;
16001600 ssl->dupSide = READ_DUP_SIDE;
0 commit comments