[glib-networking] Fix leak of peer certificate
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib-networking] Fix leak of peer certificate
- Date: Sat, 1 Feb 2020 23:41:40 +0000 (UTC)
commit b46d328531f984f05b8e43b621b2be36d009406e
Author: Michael Catanzaro <mcatanzaro gnome org>
Date: Sat Feb 1 16:20:39 2020 -0600
Fix leak of peer certificate
I forgot that g_set_object() refs the new object. This code is adding an
extra ref on the peer_certificate.
The certificate object should be guaranteed to be not the exact same as
the existing one, so we don't need to guard against accidental
destruction here. No reason to bother with g_set_object().
tls/base/gtlsconnection-base.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
---
diff --git a/tls/base/gtlsconnection-base.c b/tls/base/gtlsconnection-base.c
index 637d785..4fb224a 100644
--- a/tls/base/gtlsconnection-base.c
+++ b/tls/base/gtlsconnection-base.c
@@ -1292,7 +1292,8 @@ update_peer_certificate_and_compute_errors (GTlsConnectionBase *tls)
if (peer_certificate)
peer_certificate_errors = verify_peer_certificate (tls, peer_certificate);
- g_set_object (&priv->peer_certificate, peer_certificate);
+ g_clear_object (&priv->peer_certificate);
+ priv->peer_certificate = g_steal_pointer (&peer_certificate);
g_clear_object (&peer_certificate);
priv->peer_certificate_errors = peer_certificate_errors;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]