@@ -5264,7 +5264,7 @@ int wolfSSL_SetTmpDH(WOLFSSL* ssl, const unsigned char* p, int pSz,
52645264 ret = wolfssl_set_tmp_dh (ssl , pAlloc , pSz , gAlloc , gSz );
52655265 }
52665266
5267- if (ret != 1 ) {
5267+ if (ret != 1 && ssl != NULL ) {
52685268 /* Free the allocated buffers if not assigned into SSL. */
52695269 XFREE (pAlloc , ssl -> heap , DYNAMIC_TYPE_PUBLIC_KEY );
52705270 XFREE (gAlloc , ssl -> heap , DYNAMIC_TYPE_PUBLIC_KEY );
@@ -5496,7 +5496,7 @@ long wolfSSL_set_tmp_dh(WOLFSSL *ssl, WOLFSSL_DH *dh)
54965496 ret = wolfssl_set_tmp_dh (ssl , p , pSz , g , gSz );
54975497 }
54985498
5499- if (ret != 1 ) {
5499+ if (ret != 1 && ssl != NULL ) {
55005500 /* Free the allocated buffers if not assigned into SSL. */
55015501 XFREE (p , ssl -> heap , DYNAMIC_TYPE_PUBLIC_KEY );
55025502 XFREE (g , ssl -> heap , DYNAMIC_TYPE_PUBLIC_KEY );
@@ -5563,7 +5563,7 @@ long wolfSSL_CTX_set_tmp_dh(WOLFSSL_CTX* ctx, WOLFSSL_DH* dh)
55635563 ret = wolfssl_ctx_set_tmp_dh (ctx , p , pSz , g , gSz );
55645564 }
55655565
5566- if (ret != 1 ) {
5566+ if (ret != 1 && ctx != NULL ) {
55675567 /* Free the allocated buffers if not assigned into SSL. */
55685568 XFREE (p , ctx -> heap , DYNAMIC_TYPE_PUBLIC_KEY );
55695569 XFREE (g , ctx -> heap , DYNAMIC_TYPE_PUBLIC_KEY );
0 commit comments