From 4b09d2b4d3958b58b020c1ae21fcd932e1eb6c37 Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Wed, 20 Mar 2013 22:20:25 +0100 Subject: Fix memory leaks reported by 'make leakcheck' --- common/mock.c | 4 +++- common/pem.c | 1 + common/tests/test-hash.c | 2 ++ common/tests/test-utf8.c | 4 ++++ common/tests/test-x509.c | 1 + 5 files changed, 11 insertions(+), 1 deletion(-) (limited to 'common') diff --git a/common/mock.c b/common/mock.c index 3ba3085..9d6c960 100644 --- a/common/mock.c +++ b/common/mock.c @@ -119,8 +119,10 @@ static void free_session (void *data) { Session *sess = (Session *)data; - if (sess) + if (sess) { p11_dict_free (sess->objects); + p11_array_free (sess->matches); + } free (sess); } diff --git a/common/pem.c b/common/pem.c index b3c6acd..b0625ef 100644 --- a/common/pem.c +++ b/common/pem.c @@ -227,6 +227,7 @@ p11_pem_parse (const char *data, if (sink != NULL) (sink) (type, decoded, n_decoded, user_data); ++nfound; + free (decoded); } } diff --git a/common/tests/test-hash.c b/common/tests/test-hash.c index d6d7990..c8694e1 100644 --- a/common/tests/test-hash.c +++ b/common/tests/test-hash.c @@ -89,6 +89,8 @@ test_sha1_long (CuTest *cu) p11_hash_sha1 (checksum, input, 1000000, NULL); CuAssertTrue (cu, memcmp (expected, checksum, P11_HASH_SHA1_LEN) == 0); + + free (input); } const char *md5_input[] = { diff --git a/common/tests/test-utf8.c b/common/tests/test-utf8.c index d34f597..ed13fa2 100644 --- a/common/tests/test-utf8.c +++ b/common/tests/test-utf8.c @@ -38,6 +38,7 @@ #include "utf8.h" #include +#include #define ELEMS(x) (sizeof (x) / sizeof (x[0])) @@ -74,6 +75,7 @@ test_ucs2be (CuTest *cu) CuAssertIntEquals (cu, fixtures[i].output_len, length); CuAssertStrEquals (cu, fixtures[i].output, output); + free (output); } } @@ -146,6 +148,8 @@ test_ucs4be (CuTest *cu) CuAssertIntEquals (cu, fixtures[i].output_len, length); CuAssertStrEquals (cu, fixtures[i].output, output); + + free (output); } } diff --git a/common/tests/test-x509.c b/common/tests/test-x509.c index 08c269d..2596c9c 100644 --- a/common/tests/test-x509.c +++ b/common/tests/test-x509.c @@ -397,6 +397,7 @@ test_directory_string (CuTest *tc) CuAssertIntEquals (tc, fixtures[i].output_len, length); CuAssertStrEquals (tc, fixtures[i].output, string); + free (string); } } -- cgit v1.1