Make sure everything that may be freed is allocated or initiated.
[openssl.git] / crypto / bn / bn_prime.c
index a9ec01d9160b90739028d358908e21135f2d2e56..6c16029957ed7f43eac0c4783e3c68989121af4c 100644 (file)
@@ -142,11 +142,11 @@ int BN_GENCB_call(BN_GENCB *cb, int a, int b)
                {
        case 1:
                /* Deprecated-style callbacks */
-               cb->cb_1(a, b, cb->arg);
+               cb->cb.cb_1(a, b, cb->arg);
                return 1;
        case 2:
                /* New-style callbacks */
-               return cb->cb_2(a, b, cb);
+               return cb->cb.cb_2(a, b, cb);
        default:
                break;
                }
@@ -163,9 +163,9 @@ int BN_generate_prime_ex(BIGNUM *ret, int bits, int safe,
        BN_CTX *ctx;
        int checks = BN_prime_checks_for_size(bits);
 
+       BN_init(&t);
        ctx=BN_CTX_new();
        if (ctx == NULL) goto err;
-       BN_init(&t);
 loop: 
        /* make a random number and set the top and bottom bits */
        if (add == NULL)