summaryrefslogtreecommitdiffstats
path: root/crypto/tlscredsx509.c
diff options
context:
space:
mode:
authorKevin Wolf2020-11-30 11:56:14 +0100
committerDaniel P. Berrangé2021-01-29 18:07:53 +0100
commitab366aae78bcac972a0920ffdda3136fc13fa093 (patch)
treed047381b8fe8f2b1bdf823b3aa4f604e75e91029 /crypto/tlscredsx509.c
parentcrypto: Forbid broken unloading of secrets (diff)
downloadqemu-ab366aae78bcac972a0920ffdda3136fc13fa093.tar.gz
qemu-ab366aae78bcac972a0920ffdda3136fc13fa093.tar.xz
qemu-ab366aae78bcac972a0920ffdda3136fc13fa093.zip
crypto: Fix memory leaks in set_loaded for tls-*
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 <kwolf@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Diffstat (limited to 'crypto/tlscredsx509.c')
-rw-r--r--crypto/tlscredsx509.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/crypto/tlscredsx509.c b/crypto/tlscredsx509.c
index c89dd62435..dbadad4df2 100644
--- a/crypto/tlscredsx509.c
+++ b/crypto/tlscredsx509.c
@@ -694,10 +694,9 @@ qcrypto_tls_creds_x509_prop_set_loaded(Object *obj,
{
QCryptoTLSCredsX509 *creds = QCRYPTO_TLS_CREDS_X509(obj);
+ qcrypto_tls_creds_x509_unload(creds);
if (value) {
qcrypto_tls_creds_x509_load(creds, errp);
- } else {
- qcrypto_tls_creds_x509_unload(creds);
}
}