X-Git-Url: https://git.openssl.org/gitweb/?a=blobdiff_plain;f=crypto%2Fdh%2Fdh_gen.c;h=7a6a38fbb4849368beeff620a3611f9d0e6c60ef;hb=e815d3015eba4e54f414636b8907e15e249d72cf;hp=f0ee43ed8708338ae0766583916de6613ab4a8eb;hpb=4486d0cd7a715aed7ca3728aa24413d91666bb68;p=openssl.git diff --git a/crypto/dh/dh_gen.c b/crypto/dh/dh_gen.c index f0ee43ed87..7a6a38fbb4 100644 --- a/crypto/dh/dh_gen.c +++ b/crypto/dh/dh_gen.c @@ -95,9 +95,10 @@ DH *DH_generate_parameters(int prime_len, int generator, if (ret == NULL) goto err; ctx=BN_CTX_new(); if (ctx == NULL) goto err; - t1= &(ctx->bn[0]); - t2= &(ctx->bn[1]); - ctx->tos=2; + BN_CTX_start(ctx); + t1 = BN_CTX_get(ctx); + t2 = BN_CTX_get(ctx); + if (t1 == NULL || t2 == NULL) goto err; if (generator == DH_GENERATOR_2) { @@ -138,7 +139,11 @@ err: ok=0; } - if (ctx != NULL) BN_CTX_free(ctx); + if (ctx != NULL) + { + BN_CTX_end(ctx); + BN_CTX_free(ctx); + } if (!ok && (ret != NULL)) { DH_free(ret);