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 at 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

Reply via email to