Do to DH and DSA what has already been done to RSA. This involves moving
authorGeoff Thorpe <geoff@openssl.org>
Wed, 29 Nov 2000 19:59:45 +0000 (19:59 +0000)
committerGeoff Thorpe <geoff@openssl.org>
Wed, 29 Nov 2000 19:59:45 +0000 (19:59 +0000)
the initialisation and cleanup of "ex_data" elements to before an init()
handler and after a finish() handler respectively.

crypto/dh/dh_lib.c
crypto/dsa/dsa_lib.c

index fcb8142..c0a2472 100644 (file)
@@ -168,13 +168,13 @@ DH *DH_new_method(ENGINE *engine)
        ret->method_mont_p=NULL;
        ret->references = 1;
        ret->flags=meth->flags;
+       CRYPTO_new_ex_data(dh_meth,ret,&ret->ex_data);
        if ((meth->init != NULL) && !meth->init(ret))
                {
+               CRYPTO_free_ex_data(dh_meth,ret,&ret->ex_data);
                OPENSSL_free(ret);
                ret=NULL;
                }
-       else
-               CRYPTO_new_ex_data(dh_meth,ret,&ret->ex_data);
        return(ret);
        }
 
@@ -196,12 +196,12 @@ void DH_free(DH *r)
        }
 #endif
 
-       CRYPTO_free_ex_data(dh_meth, r, &r->ex_data);
-
        meth = ENGINE_get_DH(r->engine);
        if(meth->finish) meth->finish(r);
        ENGINE_finish(r->engine);
 
+       CRYPTO_free_ex_data(dh_meth, r, &r->ex_data);
+
        if (r->p != NULL) BN_clear_free(r->p);
        if (r->g != NULL) BN_clear_free(r->g);
        if (r->q != NULL) BN_clear_free(r->q);
index 5e5bff8..6002711 100644 (file)
@@ -173,13 +173,13 @@ DSA *DSA_new_method(ENGINE *engine)
 
        ret->references=1;
        ret->flags=meth->flags;
+       CRYPTO_new_ex_data(dsa_meth,ret,&ret->ex_data);
        if ((meth->init != NULL) && !meth->init(ret))
                {
+               CRYPTO_free_ex_data(dsa_meth,ret,&ret->ex_data);
                OPENSSL_free(ret);
                ret=NULL;
                }
-       else
-               CRYPTO_new_ex_data(dsa_meth,ret,&ret->ex_data);
        
        return(ret);
        }
@@ -204,12 +204,12 @@ void DSA_free(DSA *r)
                }
 #endif
 
-       CRYPTO_free_ex_data(dsa_meth, r, &r->ex_data);
-
        meth = ENGINE_get_DSA(r->engine);
        if(meth->finish) meth->finish(r);
        ENGINE_finish(r->engine);
 
+       CRYPTO_free_ex_data(dsa_meth, r, &r->ex_data);
+
        if (r->p != NULL) BN_clear_free(r->p);
        if (r->q != NULL) BN_clear_free(r->q);
        if (r->g != NULL) BN_clear_free(r->g);