@@ -201,22 +201,24 @@ static WOLFPROV_CTX* wolfssl_prov_ctx_new(void)
201201 }
202202#endif
203203
204- ctx -> coreBioMethod = BIO_meth_new (BIO_TYPE_CORE_TO_PROV , "BIO to Core filter" );
205- if (ctx -> coreBioMethod == NULL
206- || !BIO_meth_set_write_ex (ctx -> coreBioMethod , bio_core_write_ex )
207- || !BIO_meth_set_read_ex (ctx -> coreBioMethod , bio_core_read_ex )
208- || !BIO_meth_set_puts (ctx -> coreBioMethod , bio_core_puts )
209- || !BIO_meth_set_gets (ctx -> coreBioMethod , bio_core_gets )
210- || !BIO_meth_set_ctrl (ctx -> coreBioMethod , bio_core_ctrl )
211- || !BIO_meth_set_create (ctx -> coreBioMethod , bio_core_new )
212- || !BIO_meth_set_destroy (ctx -> coreBioMethod , bio_core_free )) {
213- BIO_meth_free (ctx -> coreBioMethod );
204+ if (ctx != NULL ) {
205+ ctx -> coreBioMethod = BIO_meth_new (BIO_TYPE_CORE_TO_PROV , "BIO to Core filter" );
206+ if (ctx -> coreBioMethod == NULL
207+ || !BIO_meth_set_write_ex (ctx -> coreBioMethod , bio_core_write_ex )
208+ || !BIO_meth_set_read_ex (ctx -> coreBioMethod , bio_core_read_ex )
209+ || !BIO_meth_set_puts (ctx -> coreBioMethod , bio_core_puts )
210+ || !BIO_meth_set_gets (ctx -> coreBioMethod , bio_core_gets )
211+ || !BIO_meth_set_ctrl (ctx -> coreBioMethod , bio_core_ctrl )
212+ || !BIO_meth_set_create (ctx -> coreBioMethod , bio_core_new )
213+ || !BIO_meth_set_destroy (ctx -> coreBioMethod , bio_core_free )) {
214+ BIO_meth_free (ctx -> coreBioMethod );
214215#ifndef WP_SINGLE_THREADED
215- wc_FreeMutex (& ctx -> rng_mutex );
216+ wc_FreeMutex (& ctx -> rng_mutex );
216217#endif
217- wc_FreeRng (& ctx -> rng );
218- OPENSSL_free (ctx );
219- ctx = NULL ;
218+ wc_FreeRng (& ctx -> rng );
219+ OPENSSL_free (ctx );
220+ ctx = NULL ;
221+ }
220222 }
221223
222224 return ctx ;
0 commit comments