diff --git a/gio/gtlscertificate.c b/gio/gtlscertificate.c index 4374ac21a..ca09b180a 100644 --- a/gio/gtlscertificate.c +++ b/gio/gtlscertificate.c @@ -626,7 +626,7 @@ create_certificate_chain_from_list (GSList *pem_list, /* root will point to the last certificate in the file. */ if (!root) - root = cert; + root = g_object_ref (cert); pem = g_slist_next (pem); } @@ -641,6 +641,8 @@ create_certificate_chain_from_list (GSList *pem_list, g_clear_object (&cert); } + g_clear_object (&root); + return cert; }