From 8a9583a14724ea6a25100532d1e46c1721a4680c Mon Sep 17 00:00:00 2001 From: Jack Lloyd Date: Fri, 6 Jan 2017 11:58:00 -0500 Subject: Avoid using uninitialized RNG object in tests if construction fails Found by Coverity scanner --- src/tests/test_ffi.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src/tests/test_ffi.cpp') diff --git a/src/tests/test_ffi.cpp b/src/tests/test_ffi.cpp index 243583e8f..3e272d9cb 100644 --- a/src/tests/test_ffi.cpp +++ b/src/tests/test_ffi.cpp @@ -79,10 +79,17 @@ class FFI_Unit_Tests : public Test TEST_FFI_OK(botan_rng_destroy, (rng)); } - TEST_FFI_OK(botan_rng_init, (&rng, "user")); - TEST_FFI_OK(botan_rng_get, (rng, outbuf.data(), outbuf.size())); - TEST_FFI_OK(botan_rng_reseed, (rng, 256)); - // used for the rest of this function and destroyed at the end + if(TEST_FFI_OK(botan_rng_init, (&rng, "user"))) + { + TEST_FFI_OK(botan_rng_get, (rng, outbuf.data(), outbuf.size())); + TEST_FFI_OK(botan_rng_reseed, (rng, 256)); + // used for the rest of this function and destroyed at the end + } + else + { + result.test_note("Existing early due to missing FFI RNG"); + return {result}; + } // hashing test botan_hash_t hash; -- cgit v1.2.3