GNOME Bugzilla – Bug 768845
Don't leak the GSimpleAsyncResult and object path during sign_in_identity
Last modified: 2016-07-15 16:09:26 UTC
sign_in_identity_sync returns a newly allocated object_path. sign_in_thread transfers this pointer back to the calling thread via the GSimpleAsyncResult without using a GDestroyNotify. This is then read out by on_initial_sign_in_done. So far so good. The async version matches the sync version by returning a newly allocated string. However, on_initial_sign_in_done should now free the string when it is done with it. It doesn't. I couldn't get valgrind to detect this leak. Maybe I just missed it in the logs.
Created attachment 331592 [details] [review] kerberos: Don't leak the object path from sign_in_identity
We are also leaking the GSimpleAsyncResult that is used to implement sign_in_identity.
Review of attachment 331592 [details] [review]: oh nice find! fix seems reasonable to me. Any particular reason you went this route over using the GDestroyNotify ?
Created attachment 331597 [details] [review] kerberos: Don't leak the GSimpleAsyncResult in sign_in_identity
By the way, I found these while playing with Christophe's GTask patches in bug 764157
Review of attachment 331597 [details] [review]: clearly right
(In reply to Ray Strode [halfline] from comment #3) > Review of attachment 331592 [details] [review] [review]: > > oh nice find! fix seems reasonable to me. Any particular reason you went > this route over using the GDestroyNotify ? Overall, I wanted the async variant to match its sync counterpart for consistency So, the callback of sign_in_identity should get a new string. Now, I could have used a GDestroyNotify with g_simple_async_result_set_op_res_gpointer but GSimpleAsyncResult is a bit weird and different from GTask in this aspect. Unlike g_task_propagate_pointer, g_simple_async_result_get_op_res_gpointer doesn't transfer ownership (see bug 683376). So, if we use a GDestroyNotify, we either need to g_strdup the return value or NULLify the op_res inside the GSimpleAsyncResult.
Thanks for the reviews, halfline!