From ab366aae78bcac972a0920ffdda3136fc13fa093 Mon Sep 17 00:00:00 2001 From: Kevin Wolf Date: Mon, 30 Nov 2020 11:56:14 +0100 Subject: crypto: Fix memory leaks in set_loaded for tls-* MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If you set the loaded property to true when it was already true, the state is overwritten without freeing the old state first. Change the set_loaded callback so that it always frees the old state (which is a no-op if nothing was loaded) and only then load if requestsd. Signed-off-by: Kevin Wolf Signed-off-by: Daniel P. Berrangé --- crypto/tlscredsanon.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'crypto/tlscredsanon.c') diff --git a/crypto/tlscredsanon.c b/crypto/tlscredsanon.c index 30275b6847..bea5f76c55 100644 --- a/crypto/tlscredsanon.c +++ b/crypto/tlscredsanon.c @@ -123,10 +123,9 @@ qcrypto_tls_creds_anon_prop_set_loaded(Object *obj, { QCryptoTLSCredsAnon *creds = QCRYPTO_TLS_CREDS_ANON(obj); + qcrypto_tls_creds_anon_unload(creds); if (value) { qcrypto_tls_creds_anon_load(creds, errp); - } else { - qcrypto_tls_creds_anon_unload(creds); } } -- cgit v1.2.3