diff --git a/gio/gtlscertificate.c b/gio/gtlscertificate.c index d0a326b27..975117042 100644 --- a/gio/gtlscertificate.c +++ b/gio/gtlscertificate.c @@ -624,7 +624,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); } @@ -639,6 +639,8 @@ create_certificate_chain_from_list (GSList *pem_list, g_clear_object (&cert); } + g_clear_object (&root); + return cert; }