GNOME Bugzilla – Bug 564677
app/sheets_dialog_callbacks.c:1504: Memory leak: so
Last modified: 2009-01-11 23:17:00 UTC
In file app/sheets_dialog_callbacks.c:1504 Variable "so" allocates memory using g_new0() and then value of the pointer is assigned to som_new->sheet_object, and after that memory allocated by "so" is not released ever. I think the assignment acts like a memcpy, giving the som_new a copy of it. You could probably do the same without allocating so any memory at all, by using the memory allocated by som_new, but I can't tell I fully understand what is going on here. Easy fix probably is to release memory allocated by "so" after the assignment to sheet_object. so = g_new0(SheetObject, 1); so->object_type = g_strdup(som->sheet_object.object_type); so->description = g_strdup(som->sheet_object.description); so->pixmap = som->sheet_object.pixmap; so->user_data = som->sheet_object.user_data; so->user_data_type = som->sheet_object.user_data_type; so->line_break = FALSE; /* must be false--we don't copy linebreaks */ so->pixmap_file = g_strdup(som->sheet_object.pixmap_file); so->has_icon_on_sheet = som->sheet_object.has_icon_on_sheet; som_new = g_new0(SheetObjectMod, 1); som_new->sheet_object = *so; This bug was found using cppcheck: http://cppcheck.wiki.sourceforge.net/
Thanks, good catch: 2009-01-12 Hans Breuer <hans@breuer.org> * app/sheets_dialog_callbacks.c : don't leak a superfluous SheetObject fixes bug #564677