summaryrefslogtreecommitdiffstats
path: root/test/evp_test.c
diff options
context:
space:
mode:
authorPauli <paul.dale@oracle.com>2017-07-06 09:10:28 +1000
committerPauli <paul.dale@oracle.com>2017-07-14 07:31:29 +1000
commit9e206ce5f80172136b503ca23fbd8e53b78eb4b7 (patch)
treed3942855040ebee306a234140f9f62b5d33177f3 /test/evp_test.c
parentd72a00416a0691bfd4920008767221bb4082a2ed (diff)
Fix some issues raise by coverity in the tests.
Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/3846)
Diffstat (limited to 'test/evp_test.c')
-rw-r--r--test/evp_test.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/test/evp_test.c b/test/evp_test.c
index 36e29c4bec..700923b091 100644
--- a/test/evp_test.c
+++ b/test/evp_test.c
@@ -1023,8 +1023,11 @@ static int pkey_test_init(EVP_TEST *t, const char *name,
return 0;
}
kdata->keyop = keyop;
- if (!TEST_ptr(kdata->ctx = EVP_PKEY_CTX_new(pkey, NULL)))
+ if (!TEST_ptr(kdata->ctx = EVP_PKEY_CTX_new(pkey, NULL))) {
+ EVP_PKEY_free(pkey);
+ OPENSSL_free(kdata);
return 0;
+ }
if (keyopinit(kdata->ctx) <= 0)
t->err = "KEYOP_INIT_ERROR";
t->data = kdata;
@@ -1624,10 +1627,15 @@ static int kdf_test_init(EVP_TEST *t, const char *name)
if (!TEST_ptr(kdata = OPENSSL_zalloc(sizeof(*kdata))))
return 0;
kdata->ctx = EVP_PKEY_CTX_new_id(OBJ_sn2nid(name), NULL);
- if (kdata->ctx == NULL)
+ if (kdata->ctx == NULL) {
+ OPENSSL_free(kdata);
return 0;
- if (EVP_PKEY_derive_init(kdata->ctx) <= 0)
+ }
+ if (EVP_PKEY_derive_init(kdata->ctx) <= 0) {
+ EVP_PKEY_CTX_free(kdata->ctx);
+ OPENSSL_free(kdata);
return 0;
+ }
t->data = kdata;
return 1;
}