* [PATCH 1/2] * notmuch-config: fix small leak from 'g_key_file_to_data' @ 2009-12-02 7:11 Dirk-Jan C. Binnema 2009-12-02 7:11 ` [PATCH 2/2] * free the response data from 'prompt' Dirk-Jan C. Binnema 0 siblings, 1 reply; 3+ messages in thread From: Dirk-Jan C. Binnema @ 2009-12-02 7:11 UTC (permalink / raw) To: notmuch Signed-off-by: Dirk-Jan C. Binnema <djcb.bulk@gmail.com> --- notmuch-config.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/notmuch-config.c b/notmuch-config.c index fc65d6b..95430db 100644 --- a/notmuch-config.c +++ b/notmuch-config.c @@ -317,9 +317,11 @@ notmuch_config_save (notmuch_config_t *config) fprintf (stderr, "Error saving configuration to %s: %s\n", config->filename, error->message); g_error_free (error); + g_free (data); return 1; } + g_free (data); return 0; } -- 1.6.3.3 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] * free the response data from 'prompt' 2009-12-02 7:11 [PATCH 1/2] * notmuch-config: fix small leak from 'g_key_file_to_data' Dirk-Jan C. Binnema @ 2009-12-02 7:11 ` Dirk-Jan C. Binnema 2009-12-04 19:18 ` Carl Worth 0 siblings, 1 reply; 3+ messages in thread From: Dirk-Jan C. Binnema @ 2009-12-02 7:11 UTC (permalink / raw) To: notmuch Free the results of the prompt; this patch does the minimal job for that. It may be nice to refactor the function a bit. Signed-off-by: Dirk-Jan C. Binnema <djcb.bulk@gmail.com> --- notmuch-setup.c | 15 +++++++++++++-- 1 files changed, 13 insertions(+), 2 deletions(-) diff --git a/notmuch-setup.c b/notmuch-setup.c index 622bbaa..293c852 100644 --- a/notmuch-setup.c +++ b/notmuch-setup.c @@ -119,12 +119,16 @@ notmuch_setup_command (unused (void *ctx), prompt ("Your full name [%s]: ", notmuch_config_get_user_name (config)); if (strlen (response)) notmuch_config_set_user_name (config, response); - + free (response); + response = NULL; + prompt ("Your primary email address [%s]: ", notmuch_config_get_user_primary_email (config)); if (strlen (response)) notmuch_config_set_user_primary_email (config, response); - + free (response); + response = NULL; + other_emails = g_ptr_array_new (); old_other_emails = notmuch_config_get_user_other_email (config, @@ -136,12 +140,17 @@ notmuch_setup_command (unused (void *ctx), else g_ptr_array_add (other_emails, talloc_strdup (ctx, old_other_emails[i])); + free (response); + response = NULL; } do { prompt ("Additional email address [Press 'Enter' if none]: "); if (strlen (response)) g_ptr_array_add (other_emails, talloc_strdup (ctx, response)); + free (response); + response = NULL; + } while (strlen (response)); if (other_emails->len) notmuch_config_set_user_other_email (config, @@ -158,6 +167,8 @@ notmuch_setup_command (unused (void *ctx), absolute_path = make_path_absolute (ctx, response); notmuch_config_set_database_path (config, absolute_path); } + free (response); + response = NULL; if (! notmuch_config_save (config)) { if (is_new) -- 1.6.3.3 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 2/2] * free the response data from 'prompt' 2009-12-02 7:11 ` [PATCH 2/2] * free the response data from 'prompt' Dirk-Jan C. Binnema @ 2009-12-04 19:18 ` Carl Worth 0 siblings, 0 replies; 3+ messages in thread From: Carl Worth @ 2009-12-04 19:18 UTC (permalink / raw) To: Dirk-Jan C. Binnema, notmuch [-- Attachment #1: Type: text/plain, Size: 662 bytes --] On Wed, 2 Dec 2009 09:11:25 +0200, "Dirk-Jan C. Binnema" <djcb.bulk@gmail.com> wrote: > Free the results of the prompt; this patch does the minimal job for that. > It may be nice to refactor the function a bit. > > Signed-off-by: Dirk-Jan C. Binnema <djcb.bulk@gmail.com> Hi there, I pushed the first leak fix from this series, but the below is doing a little more work than necessary. The getline function is happy to accept a malloc'ed pointer and return it again if it's large enough, (or otherwise realloc it and return the result). So we don't need to free response between each call to prompt, but just after the last one. -Carl [-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --] ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-12-04 19:18 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2009-12-02 7:11 [PATCH 1/2] * notmuch-config: fix small leak from 'g_key_file_to_data' Dirk-Jan C. Binnema 2009-12-02 7:11 ` [PATCH 2/2] * free the response data from 'prompt' Dirk-Jan C. Binnema 2009-12-04 19:18 ` Carl Worth
Code repositories for project(s) associated with this public inbox https://yhetil.org/notmuch.git/ This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).