diff options
author | Stef Walter <stefw@gnome.org> | 2013-03-20 22:20:25 +0100 |
---|---|---|
committer | Stef Walter <stefw@gnome.org> | 2013-03-20 22:22:30 +0100 |
commit | 4b09d2b4d3958b58b020c1ae21fcd932e1eb6c37 (patch) | |
tree | abba9eb25d2d7d4c9804ba56741e08e40b0fe417 /trust/tests | |
parent | 57d8f36a6cfbde5a9a783f11f2b75f19005c23e1 (diff) |
Fix memory leaks reported by 'make leakcheck'
Diffstat (limited to 'trust/tests')
-rw-r--r-- | trust/tests/test-builder.c | 51 | ||||
-rw-r--r-- | trust/tests/test-index.c | 5 | ||||
-rw-r--r-- | trust/tests/test-module.c | 2 |
3 files changed, 48 insertions, 10 deletions
diff --git a/trust/tests/test-builder.c b/trust/tests/test-builder.c index be5390e..3212bac 100644 --- a/trust/tests/test-builder.c +++ b/trust/tests/test-builder.c @@ -429,6 +429,7 @@ test_build_certificate_no_type (CuTest *cu) }; CK_ATTRIBUTE *attrs; + CK_ATTRIBUTE *merge; CK_RV rv; setup (cu); @@ -436,8 +437,10 @@ test_build_certificate_no_type (CuTest *cu) p11_message_quiet (); attrs = NULL; - rv = p11_builder_build (test.builder, test.index, &attrs, p11_attrs_dup (input)); + merge = p11_attrs_dup (input); + rv = p11_builder_build (test.builder, test.index, &attrs, merge); CuAssertIntEquals (cu, CKR_TEMPLATE_INCOMPLETE, rv); + p11_attrs_free (merge); p11_message_loud (); @@ -456,6 +459,7 @@ test_build_certificate_bad_type (CuTest *cu) }; CK_ATTRIBUTE *attrs; + CK_ATTRIBUTE *merge; CK_RV rv; setup (cu); @@ -463,8 +467,10 @@ test_build_certificate_bad_type (CuTest *cu) p11_message_quiet (); attrs = NULL; - rv = p11_builder_build (test.builder, test.index, &attrs, p11_attrs_dup (input)); + merge = p11_attrs_dup (input); + rv = p11_builder_build (test.builder, test.index, &attrs, merge); CuAssertIntEquals (cu, CKR_TEMPLATE_INCONSISTENT, rv); + p11_attrs_free (merge); p11_message_loud (); @@ -524,6 +530,7 @@ test_create_not_settable (CuTest *cu) }; CK_ATTRIBUTE *attrs; + CK_ATTRIBUTE *merge; CK_RV rv; setup (cu); @@ -531,8 +538,10 @@ test_create_not_settable (CuTest *cu) p11_message_quiet (); attrs = NULL; - rv = p11_builder_build (test.builder, test.index, &attrs, p11_attrs_dup (input)); + merge = p11_attrs_dup (input); + rv = p11_builder_build (test.builder, test.index, &attrs, merge); CuAssertIntEquals (cu, CKR_ATTRIBUTE_READ_ONLY, rv); + p11_attrs_free (merge); p11_message_loud (); @@ -587,6 +596,7 @@ test_create_unsupported (CuTest *cu) }; CK_ATTRIBUTE *attrs; + CK_ATTRIBUTE *merge; CK_RV rv; setup (cu); @@ -594,8 +604,10 @@ test_create_unsupported (CuTest *cu) p11_message_quiet (); attrs = NULL; - rv = p11_builder_build (test.builder, test.index, &attrs, p11_attrs_dup (input)); + merge = p11_attrs_dup (input); + rv = p11_builder_build (test.builder, test.index, &attrs, merge); CuAssertIntEquals (cu, CKR_TEMPLATE_INCONSISTENT, rv); + p11_attrs_free (merge); p11_message_loud (); @@ -613,6 +625,7 @@ test_create_generated (CuTest *cu) }; CK_ATTRIBUTE *attrs; + CK_ATTRIBUTE *merge; CK_RV rv; setup (cu); @@ -620,8 +633,10 @@ test_create_generated (CuTest *cu) p11_message_quiet (); attrs = NULL; - rv = p11_builder_build (test.builder, test.index, &attrs, p11_attrs_dup (input)); + merge = p11_attrs_dup (input); + rv = p11_builder_build (test.builder, test.index, &attrs, merge); CuAssertIntEquals (cu, CKR_TEMPLATE_INCONSISTENT, rv); + p11_attrs_free (merge); p11_message_loud (); @@ -639,6 +654,7 @@ test_create_bad_attribute (CuTest *cu) }; CK_ATTRIBUTE *attrs; + CK_ATTRIBUTE *merge; CK_RV rv; setup (cu); @@ -646,8 +662,10 @@ test_create_bad_attribute (CuTest *cu) p11_message_quiet (); attrs = NULL; - rv = p11_builder_build (test.builder, test.index, &attrs, p11_attrs_dup (input)); + merge = p11_attrs_dup (input); + rv = p11_builder_build (test.builder, test.index, &attrs, merge); CuAssertIntEquals (cu, CKR_TEMPLATE_INCONSISTENT, rv); + p11_attrs_free (merge); p11_message_loud (); @@ -663,6 +681,7 @@ test_create_missing_attribute (CuTest *cu) }; CK_ATTRIBUTE *attrs; + CK_ATTRIBUTE *merge; CK_RV rv; setup (cu); @@ -670,8 +689,10 @@ test_create_missing_attribute (CuTest *cu) p11_message_quiet (); attrs = NULL; - rv = p11_builder_build (test.builder, test.index, &attrs, p11_attrs_dup (input)); + merge = p11_attrs_dup (input); + rv = p11_builder_build (test.builder, test.index, &attrs, merge); CuAssertIntEquals (cu, CKR_TEMPLATE_INCOMPLETE, rv); + p11_attrs_free (merge); p11_message_loud (); @@ -687,6 +708,7 @@ test_create_no_class (CuTest *cu) }; CK_ATTRIBUTE *attrs; + CK_ATTRIBUTE *merge; CK_RV rv; setup (cu); @@ -694,8 +716,10 @@ test_create_no_class (CuTest *cu) p11_message_quiet (); attrs = NULL; - rv = p11_builder_build (test.builder, test.index, &attrs, p11_attrs_dup (input)); + merge = p11_attrs_dup (input); + rv = p11_builder_build (test.builder, test.index, &attrs, merge); CuAssertIntEquals (cu, CKR_TEMPLATE_INCOMPLETE, rv); + p11_attrs_free (merge); p11_message_loud (); @@ -712,6 +736,7 @@ test_create_token_mismatch (CuTest *cu) }; CK_ATTRIBUTE *attrs; + CK_ATTRIBUTE *merge; CK_RV rv; setup (cu); @@ -719,8 +744,10 @@ test_create_token_mismatch (CuTest *cu) p11_message_quiet (); attrs = NULL; - rv = p11_builder_build (test.builder, test.index, &attrs, p11_attrs_dup (input)); + merge = p11_attrs_dup (input); + rv = p11_builder_build (test.builder, test.index, &attrs, merge); CuAssertIntEquals (cu, CKR_TEMPLATE_INCONSISTENT, rv); + p11_attrs_free (merge); p11_message_loud (); @@ -800,6 +827,7 @@ test_modify_read_only (CuTest *cu) merge = p11_attrs_dup (modify); rv = p11_builder_build (test.builder, test.index, &attrs, merge); CuAssertIntEquals (cu, CKR_ATTRIBUTE_READ_ONLY, rv); + p11_attrs_free (merge); p11_message_loud (); @@ -869,6 +897,7 @@ test_modify_not_modifiable (CuTest *cu) }; CK_ATTRIBUTE *attrs; + CK_ATTRIBUTE *merge; CK_RV rv; setup (cu); @@ -879,8 +908,10 @@ test_modify_not_modifiable (CuTest *cu) p11_message_quiet (); - rv = p11_builder_build (test.builder, test.index, &attrs, p11_attrs_dup (modify)); + merge = p11_attrs_dup (modify); + rv = p11_builder_build (test.builder, test.index, &attrs, merge); CuAssertIntEquals (cu, CKR_ATTRIBUTE_READ_ONLY, rv); + p11_attrs_free (merge); p11_message_loud (); diff --git a/trust/tests/test-index.c b/trust/tests/test-index.c index d58a510..14f5a8a 100644 --- a/trust/tests/test-index.c +++ b/trust/tests/test-index.c @@ -192,6 +192,7 @@ test_snapshot (CuTest *cu) for (i = 0; i < NUM; i++) CuAssertIntEquals (cu, expected[i], snapshot[i]); + free (snapshot); teardown (cu); } @@ -229,6 +230,7 @@ test_snapshot_base (CuTest *cu) for (i = 0; i < NUM * 2; i++) CuAssertIntEquals (cu, expected[i / 2], snapshot[i]); + free (snapshot); teardown (cu); } @@ -665,6 +667,7 @@ test_replace_all (CuTest *tc) CuAssertTrue (tc, rv == CKR_OK); CuAssertIntEquals (tc, 0, array->num); + p11_array_free (array); /* eins should have replaced one */ check = p11_index_find (test.index, eins, -1); @@ -1021,6 +1024,8 @@ test_change_nested (CuTest *cu) CuAssertTrue (cu, rv == CKR_OK); p11_index_finish (index); CuAssertIntEquals (cu, 1, on_change_called); + + p11_index_free (index); } int diff --git a/trust/tests/test-module.c b/trust/tests/test-module.c index 1d97f9b..1033b05 100644 --- a/trust/tests/test-module.c +++ b/trust/tests/test-module.c @@ -431,6 +431,8 @@ check_has_trust_object (CuTest *cu, check_trust_object_equiv (cu, sessions[0], objects[0], cert); check_trust_object_hashes (cu, sessions[0], objects[0], cert); + + p11_attrs_free (match); } static void |