unit-tests: Free allocated SPIs in mock IPsec backend

This commit is contained in:
Tobias Brunner 2020-10-15 18:33:26 +02:00
parent 29b491ed9c
commit 610745e724
1 changed files with 12 additions and 1 deletions

View File

@ -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);
}