diff options
author | Jack Lloyd <[email protected]> | 2017-01-06 11:58:00 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2017-01-06 11:58:00 -0500 |
commit | 8a9583a14724ea6a25100532d1e46c1721a4680c (patch) | |
tree | a2e376f277cc23a91eba08440a0cc7e02f6871da /src | |
parent | 11b357b343c7e10d693e3c77d3ba6b06c79e14f9 (diff) |
Avoid using uninitialized RNG object in tests if construction fails
Found by Coverity scanner
Diffstat (limited to 'src')
-rw-r--r-- | src/tests/test_ffi.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
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; |