From: Tobias Brunner Date: Tue, 4 Mar 2025 14:30:25 +0000 (+0100) Subject: receiver: Properly clean up if hasher or RNG can't be created X-Git-Tag: 6.0.1~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4e2cf589610ff7f1c3db413a0670e3f8539a4a4c;p=thirdparty%2Fstrongswan.git receiver: Properly clean up if hasher or RNG can't be created --- diff --git a/src/libcharon/network/receiver.c b/src/libcharon/network/receiver.c index 0b2da1afaf..e79d597440 100644 --- a/src/libcharon/network/receiver.c +++ b/src/libcharon/network/receiver.c @@ -656,8 +656,8 @@ METHOD(receiver_t, del_esp_cb, void, METHOD(receiver_t, destroy, void, private_receiver_t *this) { - this->rng->destroy(this->rng); - this->hasher->destroy(this->hasher); + DESTROY_IF(this->rng); + DESTROY_IF(this->hasher); this->esp_cb_mutex->destroy(this->esp_cb_mutex); free(this); } @@ -717,15 +717,14 @@ receiver_t *receiver_create() if (!this->hasher) { DBG1(DBG_NET, "creating cookie hasher failed, no hashers supported"); - free(this); + destroy(this); return NULL; } this->rng = lib->crypto->create_rng(lib->crypto, RNG_STRONG); if (!this->rng) { DBG1(DBG_NET, "creating cookie RNG failed, no RNG supported"); - this->hasher->destroy(this->hasher); - free(this); + destroy(this); return NULL; } if (!this->rng->get_bytes(this->rng, SECRET_LENGTH, this->secret))