GNOME Bugzilla – Bug 476849
Invocation of the interface "g_hook_free" fails in certain conditions
Last modified: 2007-09-19 20:36:49 UTC
Steps to reproduce: 1. Invocation of the interface g_hook_free fails if "finalize_hook" member of the struct GHookList is set to NULL. According to the documentation of the interface g_hook_free: Calls the GHookList hook_free function if it exists, and frees the memory allocated for the GHook. In this excerpt the phrase "hook_free function" should be read as "finalize_hook function", since the actual interface called in the source code is the "finalize_hook", while the "hook_free" identifier is not used anywhere in the code. Stack trace:
+ Trace 162844
Other information: The detailed bug description can be found at: http://linuxtesting.org/results/report?num=D0002
Created attachment 95579 [details] The test case reproducing the bug.
Created attachment 95580 [details] [review] Proposed patch, fixing the problem
Comment on attachment 95580 [details] [review] Proposed patch, fixing the problem --- glib-2.14.0/glib/ghook.c +++ glib-2.14.0-fixed/glib/ghook.c @@ -130,7 +130,8 @@ g_hook_free (GHookList *hook_list, g_return_if_fail (G_HOOK_IS_UNLINKED (hook)); g_return_if_fail (!G_HOOK_IN_CALL (hook)); - hook_list->finalize_hook (hook_list, hook); + if(hook_list->finalize_hook != NULL) + hook_list->finalize_hook (hook_list, hook); g_slice_free1 (hook_list->hook_size, hook); }
Patch looks fine.
2007-09-19 Behdad Esfahbod <behdad@gnome.org> * glib/ghook.c (g_hook_free): Check for NULL finalizer. (#476849, Areg Beketovski)