bntest: don't dereference the |d| array for a zero BIGNUM.
authorEmilia Kasper <emilia@openssl.org>
Mon, 31 Aug 2015 11:57:44 +0000 (13:57 +0200)
committerEmilia Kasper <emilia@openssl.org>
Mon, 31 Aug 2015 14:53:04 +0000 (16:53 +0200)
Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit 4d04226c2ec7e7f69f6234def63631648e35e828)

crypto/bn/bntest.c

index 470d5dabf1ec9bf510a1b8fabb758af06d77b7e8..0f8e18f39600b4f15eb2fdd5e9149529de63c518 100644 (file)
@@ -516,9 +516,9 @@ int test_div_word(BIO *bp)
         do {
             BN_bntest_rand(&a, 512, -1, 0);
             BN_bntest_rand(&b, BN_BITS2, -1, 0);
-            s = b.d[0];
-        } while (!s);
+        } while (BN_is_zero(&b));
 
+        s = b.d[0];
         BN_copy(&b, &a);
         r = BN_div_word(&b, s);