summaryrefslogtreecommitdiffstats
path: root/crypto/evp
diff options
context:
space:
mode:
authorDr. Stephen Henson <steve@openssl.org>2015-03-20 23:08:30 +0000
committerDr. Stephen Henson <steve@openssl.org>2015-03-20 23:22:17 +0000
commit5724bd49a2f11e1e9663ac82f4b5e63e18da65e6 (patch)
tree8d627bc4e9f54b2562931203acfcc9827600a488 /crypto/evp
parente6abba3ad6107d35a6e8b01a1a145902edf0062d (diff)
Fix memory leak.
Reviewed-by: Emilia Käsper <emilia@openssl.org>
Diffstat (limited to 'crypto/evp')
-rw-r--r--crypto/evp/evp_test.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/crypto/evp/evp_test.c b/crypto/evp/evp_test.c
index 1b17f64b5a..152465878e 100644
--- a/crypto/evp/evp_test.c
+++ b/crypto/evp/evp_test.c
@@ -247,16 +247,27 @@ static void hex_print(const char *name, const unsigned char *buf, size_t len)
fputs("\n", stderr);
}
+static void free_expected(struct evp_test *t)
+{
+ if (t->expected_err) {
+ OPENSSL_free(t->expected_err);
+ t->expected_err = NULL;
+ }
+ if (t->out_expected) {
+ OPENSSL_free(t->out_expected);
+ OPENSSL_free(t->out_got);
+ t->out_expected = NULL;
+ t->out_got = NULL;
+ }
+}
+
static void print_expected(struct evp_test *t)
{
if (t->out_expected == NULL)
return;
hex_print("Expected:", t->out_expected, t->out_len);
hex_print("Got: ", t->out_got, t->out_len);
- OPENSSL_free(t->out_expected);
- OPENSSL_free(t->out_got);
- t->out_expected = NULL;
- t->out_got = NULL;
+ free_expected(t);
}
static int check_test_error(struct evp_test *t)
@@ -313,6 +324,7 @@ static int setup_test(struct evp_test *t, const struct evp_test_method *tmeth)
OPENSSL_free(t->expected_err);
t->expected_err = NULL;
}
+ free_expected(t);
}
t->meth = tmeth;
return 1;