diff options
Diffstat (limited to 'src/bin/psql/command.c')
-rw-r--r-- | src/bin/psql/command.c | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 4aaf657cce8..38038d415f1 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -1089,11 +1089,11 @@ exec_command(const char *cmd, /* \password -- set user password */ else if (strcmp(cmd, "password") == 0) { - char *pw1; - char *pw2; + char pw1[100]; + char pw2[100]; - pw1 = simple_prompt("Enter new password: ", 100, false); - pw2 = simple_prompt("Enter it again: ", 100, false); + simple_prompt("Enter new password: ", pw1, sizeof(pw1), false); + simple_prompt("Enter it again: ", pw2, sizeof(pw2), false); if (strcmp(pw1, pw2) != 0) { @@ -1139,9 +1139,6 @@ exec_command(const char *cmd, if (opt0) free(opt0); } - - free(pw1); - free(pw2); } /* \prompt -- prompt and set variable */ @@ -1173,7 +1170,10 @@ exec_command(const char *cmd, opt = arg1; if (!pset.inputfile) - result = simple_prompt(prompt_text, 4096, true); + { + result = (char *) pg_malloc(4096); + simple_prompt(prompt_text, result, 4096, true); + } else { if (prompt_text) @@ -1747,20 +1747,19 @@ exec_command(const char *cmd, static char * prompt_for_password(const char *username) { - char *result; + char buf[100]; if (username == NULL) - result = simple_prompt("Password: ", 100, false); + simple_prompt("Password: ", buf, sizeof(buf), false); else { char *prompt_text; prompt_text = psprintf(_("Password for user %s: "), username); - result = simple_prompt(prompt_text, 100, false); + simple_prompt(prompt_text, buf, sizeof(buf), false); free(prompt_text); } - - return result; + return pg_strdup(buf); } static bool |