After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 307267 - [PATCH] Leak in real_update_menus_volumes()
[PATCH] Leak in real_update_menus_volumes()
Status: RESOLVED FIXED
Product: nautilus
Classification: Core
Component: general
0.x.x [obsolete]
Other Linux
: High normal
: ---
Assigned To: Nautilus Maintainers
Nautilus Maintainers
Depends on:
Blocks:
 
 
Reported: 2005-06-11 11:49 UTC by Kjartan Maraas
Modified: 2005-06-20 14:38 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
patch as described (909 bytes, patch)
2005-06-12 11:08 UTC, Kjartan Maraas
reviewed Details | Review
updated patch (955 bytes, patch)
2005-06-17 14:30 UTC, Kjartan Maraas
accepted-commit_now Details | Review

Description Kjartan Maraas 2005-06-11 11:49:21 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)
Comment 1 Paolo Borelli 2005-06-12 09:46:10 UTC
yep, looks like the g_free should go out of the if.
Comment 2 Kjartan Maraas 2005-06-12 11:08:24 UTC
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 3 Martin Wehner 2005-06-15 21:22:45 UTC
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.
Comment 4 Kjartan Maraas 2005-06-17 14:30:04 UTC
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 5 Martin Wehner 2005-06-18 13:38:28 UTC
Comment on attachment 47903 [details] [review]
updated patch

Yes, please commit.
Comment 6 Christian Kirbach 2005-06-19 23:08:59 UTC
can we close this report now?
Comment 7 Kjartan Maraas 2005-06-20 14:38:20 UTC
Commited on both branches.