From 43ac3d9b44b98d44db9b1550c47e8f96a410d1e9 Mon Sep 17 00:00:00 2001 From: Kai Blin Date: Fri, 14 Dec 2007 14:04:56 +0100 Subject: r26453: Janitorial: Don't use a static char[] in smb_readline_replacement. Fix up callers to free the memory returned, as that is needed if we use the original readline function as well. (This used to be commit c81ead1c38f417d442157b21d0d389f6a540c6f9) --- source4/lib/smbreadline/smbreadline.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'source4/lib/smbreadline') diff --git a/source4/lib/smbreadline/smbreadline.c b/source4/lib/smbreadline/smbreadline.c index e5cc3522e9..a85f335b8a 100644 --- a/source4/lib/smbreadline/smbreadline.c +++ b/source4/lib/smbreadline/smbreadline.c @@ -77,13 +77,18 @@ static char *smb_readline_replacement(const char *prompt, void (*callback)(void) char **(completion_fn)(const char *text, int start, int end)) { fd_set fds; - static char line[1024]; + char *line; struct timeval timeout; int fd = STDIN_FILENO; char *ret; do_debug("%s", prompt); + line = (char *)malloc(BUFSIZ); + if (!line) { + return NULL; + } + while (1) { timeout.tv_sec = 5; timeout.tv_usec = 0; @@ -92,7 +97,7 @@ static char *smb_readline_replacement(const char *prompt, void (*callback)(void) FD_SET(fd,&fds); if (sys_select_intr(fd+1,&fds,NULL,NULL,&timeout) == 1) { - ret = x_fgets(line, sizeof(line), x_stdin); + ret = x_fgets(line, BUFSIZ, x_stdin); return ret; } if (callback) -- cgit