From 08387212649c28e208a4ac8ff5aca65eede053f9 Mon Sep 17 00:00:00 2001 From: David Benjamin Date: Thu, 29 Sep 2016 20:18:38 -0400 Subject: [PATCH] Fix bn_test under malloc tests. Change-Id: Ia020ea08431859bf268d828b5d72715295de26e6 Reviewed-on: https://boringssl-review.googlesource.com/11401 Commit-Queue: David Benjamin Reviewed-by: Adam Langley --- crypto/bn/bn_test.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crypto/bn/bn_test.cc b/crypto/bn/bn_test.cc index 0a359bda..04888100 100644 --- a/crypto/bn/bn_test.cc +++ b/crypto/bn/bn_test.cc @@ -340,7 +340,7 @@ static bool TestSquare(FileTest *t, BN_CTX *ctx) { BN_zero(zero.get()); bssl::UniquePtr ret(BN_new()), remainder(BN_new()); - if (!ret || + if (!ret || !remainder || !BN_sqr(ret.get(), a.get(), ctx) || !ExpectBIGNUMsEqual(t, "A^2", square.get(), ret.get()) || !BN_mul(ret.get(), a.get(), a.get(), ctx) || @@ -876,6 +876,10 @@ static bool TestMPI() { for (size_t i = 0; i < OPENSSL_ARRAY_SIZE(kMPITests); i++) { const MPITest &test = kMPITests[i]; bssl::UniquePtr bn(ASCIIToBIGNUM(test.base10)); + if (!bn) { + return false; + } + const size_t mpi_len = BN_bn2mpi(bn.get(), NULL); if (mpi_len > sizeof(scratch)) { fprintf(stderr, "MPI test #%u: MPI size is too large to test.\n",