From 243afff94c6eb468bec96e9637e0f1c6fe6da445 Mon Sep 17 00:00:00 2001 From: lsh123 Date: Fri, 17 May 2024 11:23:11 -0700 Subject: [PATCH] (xmlsec-gcrypt) Fix double free in xmlSecGCryptAsymKeyDataGenerate (#795) --- src/gcrypt/asymkeys.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gcrypt/asymkeys.c b/src/gcrypt/asymkeys.c index 7f409e2a1..c923af20e 100644 --- a/src/gcrypt/asymkeys.c +++ b/src/gcrypt/asymkeys.c @@ -182,6 +182,9 @@ xmlSecGCryptAsymKeyDataAdoptKey(xmlSecKeyDataPtr data, gcry_sexp_t key_pair) { pub_key = NULL; /* data owns it now */ priv_key = NULL; /* data owns it now */ + /* Adopt functions assume ownership on success thus the caller would expect this to be released */ + gcry_sexp_release(key_pair); + /* success */ res = 0; @@ -194,9 +197,6 @@ xmlSecGCryptAsymKeyDataAdoptKey(xmlSecKeyDataPtr data, gcry_sexp_t key_pair) { gcry_sexp_release(priv_key); } - /* Adopt functions assume ownership thus the caller would expect this to be released */ - gcry_sexp_release(key_pair); - /* done */ return(res); }