From 577d22dbc390b7727680960051534896c2b108e0 Mon Sep 17 00:00:00 2001 From: Heiko Hund Date: Fri, 20 Jul 2012 11:56:08 +0200 Subject: [PATCH] fix ManagementCommandFromInput() --- misc.c | 13 ++++++++----- misc.h | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/misc.c b/misc.c index 6a4127d..6d9140b 100644 --- a/misc.c +++ b/misc.c @@ -47,7 +47,7 @@ GetDlgItemTextUtf8(HWND hDlg, int id, LPSTR *str, int *len) *len = 0; ucs2_len = GetWindowTextLength(GetDlgItem(hDlg, id)) + 1; - if (ucs2_len == 0) + if (ucs2_len == 1) goto out; ucs2_str = malloc(ucs2_len * sizeof(*ucs2_str)); @@ -77,7 +77,7 @@ out: * Generate a management command from user input and send it */ BOOL -ManagementCommandFromInput(connection_t *c, LPSTR fmt, HWND hDlg, int id) +ManagementCommandFromInput(connection_t *c, LPCSTR fmt, HWND hDlg, int id) { BOOL retval = FALSE; LPSTR input, cmd; @@ -95,9 +95,12 @@ ManagementCommandFromInput(connection_t *c, LPSTR fmt, HWND hDlg, int id) } /* Clear buffers with potentially secret content */ - memset(input, 'x', input_len - 1); - SetDlgItemTextA(hDlg, id, input); - free(input); + if (input_len) + { + memset(input, 'x', input_len - 1); + SetDlgItemTextA(hDlg, id, input); + free(input); + } return retval; } diff --git a/misc.h b/misc.h index 4a351ff..f0ed32b 100644 --- a/misc.h +++ b/misc.h @@ -22,7 +22,7 @@ #ifndef MISC_H #define MISC_H -BOOL ManagementCommandFromInput(connection_t *, LPSTR, HWND, int); +BOOL ManagementCommandFromInput(connection_t *, LPCSTR, HWND, int); BOOL streq(LPCSTR, LPCSTR); BOOL wcsbegins(LPCWSTR, LPCWSTR);