GNOME Bugzilla – Bug 307267
[PATCH] Leak in real_update_menus_volumes()
Last modified: 2005-06-20 14:38:20 UTC
} else if (nautilus_file_is_nautilus_link (file)) { uri = nautilus_file_get_activation_uri (file); if (uri != NULL && (eel_istr_has_prefix (uri, "ftp:") || eel_istr_has_prefix (uri, "dav:") || eel_istr_has_prefix (uri, "davs:"))) { show_connect = TRUE; g_free (uri); } Valgrind reports a leak here, can this happen if the uri is something else than the three in the if test here? Trace: ==8732== 7 bytes in 1 blocks are definitely lost in loss record 715 of 20645 ==8732== at 0x1B909222: malloc (vg_replace_malloc.c:130) ==8732== by 0x1C4E8F55: g_malloc (gmem.c:137) ==8732== by 0x1C4F9531: g_strdup (gstrfuncs.c:91) ==8732== by 0x1B950014: nautilus_file_get_activation_uri (nautilus-file.c:2775) ==8732== by 0x808CDD1: real_update_menus_volumes (fm-directory-view.c:6325) ==8732== by 0x8093AB5: real_update_menus (fm-directory-view.c:6683) ==8732== by 0x8098590: fm_icon_view_update_menus (fm-icon-view.c:1533) ==8732== by 0x8087545: fm_directory_view_update_menus (fm-directory-view.c:7881) ==8732== by 0x8090D17: update_menus_if_pending (fm-directory-view.c:2533) ==8732== by 0x8090E0A: fm_directory_view_pop_up_selection_context_menu (fm-directory-view.c:6719) ==8732== by 0x809989D: icon_container_context_click_selection_callback (fm-icon-view.c:2036) ==8732== by 0x1C491E94: g_cclosure_marshal_VOID__POINTER (gmarshal.c:601) ==8732== by 0x1C4852FB: g_closure_invoke (gclosure.c:437) ==8732== by 0x1C494A7E: signal_emit_unlocked_R (gsignal.c:2488) ==8732== by 0x1C49605A: g_signal_emit_valist (gsignal.c:2247) ==8732== by 0x1C4963E2: g_signal_emit (gsignal.c:2291) ==8732== by 0x1B965866: item_event_callback (nautilus-icon-container.c:4517) ==8732== by 0x1BA2906A: eel_marshal_BOOLEAN__BOXED (eel-marshal.c:82) ==8732== by 0x1C4852FB: g_closure_invoke (gclosure.c:437) ==8732== by 0x1C494A7E: signal_emit_unlocked_R (gsignal.c:2488) ==8732== by 0x1C495E2B: g_signal_emit_valist (gsignal.c:2257) ==8732== by 0x1C4963E2: g_signal_emit (gsignal.c:2291) ==8732== by 0x1BA0C4D5: emit_event (eel-canvas.c:2527) ==8732== by 0x1B965DEF: button_press_event (nautilus-icon-container.c:3205) ==8732== by 0x1BDD236C: _gtk_marshal_BOOLEAN__BOXED (gtkmarshalers.c:83) ==8732== by 0x1C484E28: g_type_class_meta_marshal (gclosure.c:514) ==8732== by 0x1C4852FB: g_closure_invoke (gclosure.c:437) ==8732== by 0x1C494C62: signal_emit_unlocked_R (gsignal.c:2526) ==8732== by 0x1C495E2B: g_signal_emit_valist (gsignal.c:2257) ==8732== by 0x1C4963E2: g_signal_emit (gsignal.c:2291)
yep, looks like the g_free should go out of the if.
Created attachment 47642 [details] [review] patch as described Second hunk is related to this. The first is already filed in a different report I think
Comment on attachment 47642 [details] [review] patch as described The second chunk looks fine to commit. The first chunk looks wrong: default_app is allocated once, but potentially freed multiple times (while still being used). Also you have to use gnome_vfs_mime_application_free to free it.
Created attachment 47903 [details] [review] updated patch I moved the first hunk out of the for loop and changed it to use the gnome_vfs_mime_application_free() function to free it. Is this ok?
Comment on attachment 47903 [details] [review] updated patch Yes, please commit.
can we close this report now?
Commited on both branches.