From 70824bf9785310a5e4970696c421ddff1160c254 Mon Sep 17 00:00:00 2001 From: djcb Date: Fri, 14 Sep 2012 12:16:53 +0300 Subject: [PATCH] * mu_util_read_password: fix mem mgmt --- lib/mu-util.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/mu-util.c b/lib/mu-util.c index 8d60ac35..da752e07 100644 --- a/lib/mu-util.c +++ b/lib/mu-util.c @@ -499,22 +499,18 @@ mu_util_printerr_encoded (const char *frm, ...) char* mu_util_read_password (const char *prompt) { - char *pass, *tmp; + char *pass; g_return_val_if_fail (prompt, NULL); /* note: getpass is obsolete; replace with something better */ - tmp = getpass (prompt); - if (!tmp) { + pass = getpass (prompt); /* returns static mem, don't free */ + if (!pass) { if (errno) g_warning ("error: %s", strerror(errno)); return NULL; } - /* make sure we can free with g_free(), not free() */ - pass = g_strdup (tmp); - free (tmp); - - return pass; + return g_strdup (pass); }