about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2009-05-12 11:11:14 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2009-05-12 11:11:14 +0000
commitd1abd3e7cf53fc271e9d7c5de4f84ad3e6be42c7 (patch)
treedeeb332533ff117c6b66dce7cc2a6971eca8a0a9
parentc18b6c2c99b14301ac005e27a9472feed9a46eec (diff)
downloadzsh-d1abd3e7cf53fc271e9d7c5de4f84ad3e6be42c7.tar.gz
zsh-d1abd3e7cf53fc271e9d7c5de4f84ad3e6be42c7.tar.xz
zsh-d1abd3e7cf53fc271e9d7c5de4f84ad3e6be42c7.zip
26957: Fix some memory problems with read builtin
unposted: fix a WARN_CREATE_GLOBAL warning
-rw-r--r--ChangeLog9
-rw-r--r--Functions/Prompts/prompt_bart_setup1
-rw-r--r--Src/builtin.c21
3 files changed, 22 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index ce504f044..2a32a9e3c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2009-05-12  Peter Stephenson  <pws@csr.com>
+
+	* unposted: Functions/Prompts/prompt_bart_setup: fix a warning
+	with WARN_CREATE_GLOBAL.
+
+	* Src/builtin.c: fix some memory usage issues.
+
 2009-05-11  Peter Stephenson  <pws@csr.com>
 
 	* 26956: Etc/zsh-development-guide, Src/Zle/zle_refresh:
@@ -11691,5 +11698,5 @@
 
 *****************************************************
 * This is used by the shell to define $ZSH_PATCHLEVEL
-* $Revision: 1.4683 $
+* $Revision: 1.4684 $
 *****************************************************
diff --git a/Functions/Prompts/prompt_bart_setup b/Functions/Prompts/prompt_bart_setup
index 55dd292e8..1cc7b6f08 100644
--- a/Functions/Prompts/prompt_bart_setup
+++ b/Functions/Prompts/prompt_bart_setup
@@ -78,6 +78,7 @@ prompt_bart_precmd () {
     psvar[8]=''				# No padding until we compute it
     psvar[9]=()
 
+    typeset -g PSCOL
     # Reset the truncation widths for upcoming computations
     ((PSCOL == 1)) || { PSCOL=1 ; prompt_bart_ps1 }
     if [[ -o promptcr ]]
diff --git a/Src/builtin.c b/Src/builtin.c
index d19ad01e2..86bb3bb9c 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -5085,16 +5085,16 @@ bin_read(char *name, char **args, Options ops, UNUSED(int func))
     if (OPT_ISSET(ops,'d')) {
 	char *delimstr = OPT_ARG(ops,'d');
 #ifdef MULTIBYTE_SUPPORT
-	wint_t wc;
+	wint_t wi;
 
 	if (isset(MULTIBYTE)) {
 	    mb_metacharinit();
-	    (void)mb_metacharlenconv(delimstr, &wc);
+	    (void)mb_metacharlenconv(delimstr, &wi);
 	}
 	else
-	    wc = WEOF;
-	if (wc != WEOF)
-	    delim = (wchar_t)wc;
+	    wi = WEOF;
+	if (wi != WEOF)
+	    delim = (wchar_t)wi;
 	else
 	    delim = (wchar_t)((delimstr[0] == Meta) ?
 			      delimstr[1] ^ 32 : delimstr[0]);
@@ -5358,8 +5358,12 @@ bin_read(char *name, char **args, Options ops, UNUSED(int func))
 		wc = (wchar_t)c;
 	    }
 	    if (ret != MB_INCOMPLETE) {
-		if (ret == MB_INVALID)
+		if (ret == MB_INVALID) {
 		    memset(&mbs, 0, sizeof(mbs));
+		    /* Treat this as a single character */
+		    wc = (wchar_t)c;
+		    laststart = bptr;
+		}
 		if (bslash && wc == delim) {
 		    bslash = 0;
 		    continue;
@@ -5450,9 +5454,10 @@ bin_read(char *name, char **args, Options ops, UNUSED(int func))
 	}
 	signal_setmask(s);
 #ifdef MULTIBYTE_SUPPORT
-	if (c == EOF)
+	if (c == EOF) {
 	    gotnl = 1;
-	if (ret == MB_INCOMPLETE) {
+	    *bptr = '\0';	/* see below */
+	} else if (ret == MB_INCOMPLETE) {
 	    /*
 	     * We can only get here if there is an EOF in the
 	     * middle of a character... safest to keep the debris,