GNOME Bugzilla – Bug 688674
object: Fix memory leak
Last modified: 2012-11-19 22:28:56 UTC
Noticed while inspecting the code for a different valgrind error.
Created attachment 229402 [details] [review] object: Fix memory leak
Review of attachment 229402 [details] [review]: This is some very messy code. I tried to write it to prevent leaks as clean as I could, but I guess I failed. Not sure if you have any suggestions. ::: gi/object.c @@ -367,3 @@ - old_parent = parent; - parent = g_object_info_get_parent(old_parent); - if (!parent) All you should need to do is move this if statement under the unref(old_parent), right?
(In reply to comment #2) > Review of attachment 229402 [details] [review]: > > This is some very messy code. I tried to write it to prevent leaks as clean as > I could, but I guess I failed. Not sure if you have any suggestions. I don't have any ideas for making it simpler (well, short of the GCC cleanup macros) > ::: gi/object.c > @@ -367,3 @@ > - old_parent = parent; > - parent = g_object_info_get_parent(old_parent); > - if (!parent) > > All you should need to do is move this if statement under the > unref(old_parent), right? Yes, that would be a more minimal fix, but I think the code is clearer now; the scope of "old_parent" (now "tmp") is more constrained, and thus easier to reason about.
Review of attachment 229402 [details] [review]: OK.
Attachment 229402 [details] pushed as 69a2598 - object: Fix memory leak