From: Tobias Brunner Date: Thu, 15 Oct 2020 16:33:26 +0000 (+0200) Subject: unit-tests: Free allocated SPIs in mock IPsec backend X-Git-Tag: 5.9.1rc1~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=610745e72491ca0a6833db6b9d5e34bb8596e374;p=thirdparty%2Fstrongswan.git unit-tests: Free allocated SPIs in mock IPsec backend --- diff --git a/src/libcharon/tests/utils/mock_ipsec.c b/src/libcharon/tests/utils/mock_ipsec.c index d6172f5bd5..c91bd3683b 100644 --- a/src/libcharon/tests/utils/mock_ipsec.c +++ b/src/libcharon/tests/utils/mock_ipsec.c @@ -224,11 +224,22 @@ METHOD(kernel_ipsec_t, del_policy, status_t, return SUCCESS; } +CALLBACK(destroy_spis, void, + entry_t *entry, const void* key) +{ + /* only free allocated SPIs, other SAs that were not properly deleted will + * cause a leak */ + if (entry->alloc) + { + free(entry); + } +} + METHOD(kernel_ipsec_t, destroy, void, private_kernel_ipsec_t *this) { charon->bus->remove_listener(charon->bus, &this->listener); - this->sas->destroy(this->sas); + this->sas->destroy_function(this->sas, destroy_spis); free(this); }