summary refs log tree commit diff
diff options
context:
space:
mode:
authorMikael Magnusson <mikachu@gmail.com>2022-03-10 13:12:08 +0100
committerMikael Magnusson <mikachu@gmail.com>2022-03-30 08:08:09 +0200
commit054ccf76664c357edb6ac20cc141c9e288751c46 (patch)
tree6716b9eca819da38f7fa60ae693c589ecac9c274
parentd7b8619396d806d390126c2abd1c3ce099fe7f59 (diff)
downloadzsh-054ccf76664c357edb6ac20cc141c9e288751c46.tar.gz
zsh-054ccf76664c357edb6ac20cc141c9e288751c46.tar.xz
zsh-054ccf76664c357edb6ac20cc141c9e288751c46.zip
49820: Fix a crash when completing with combination of -Q and braces
minimal reproducer .zshrc:

  zstyle ':completion:*' completer _oldlist _complete
  setopt nolistambiguous
  autoload compinit; compinit
  compdef _foo foo;_foo() { compadd -Q -- stash@{{0,1}} }
-rw-r--r--ChangeLog17
-rw-r--r--Src/Zle/compresult.c7
2 files changed, 14 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index a525d2093..c52119fa8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,10 +1,3 @@
-2022-03-30  Jun-ichi Takimoto  <takimoto-j@kba.biglobe.ne.jp>
-
-	* 49910: Test/D07multibyte.ztst, Test/E03posix.ztst: move
-	multibyte-related incompatibility with POSIX from E03 to D07
-
-	* 49908: Test/ztst.zsh: reset LC_CTYPE to C during tests.
-
 2022-03-30  Mikael Magnusson  <mikachu@gmail.com>
 
 	* 49893: Src/Zle/comp.h, Src/Zle/compcore.c: Fix comments for
@@ -18,6 +11,16 @@
 	* 49813: Doc/Zsh/redirect.yo, Src/exec.c: <<<: Document newline
 	behavior and fix optimization
 
+	* 49820: Src/Zle/compresult.c: Fix a crash when completing with
+	combination of -Q and braces
+
+2022-03-30  Jun-ichi Takimoto  <takimoto-j@kba.biglobe.ne.jp>
+
+	* 49910: Test/D07multibyte.ztst, Test/E03posix.ztst: move
+	multibyte-related incompatibility with POSIX from E03 to D07
+
+	* 49908: Test/ztst.zsh: reset LC_CTYPE to C during tests.
+
 2022-03-29  Bart Schaefer  <schaefer@zsh.org>
 
 	* 49918: NEWS, README: Update for 49917 and 49911.
diff --git a/Src/Zle/compresult.c b/Src/Zle/compresult.c
index 8b5955819..0fed297b5 100644
--- a/Src/Zle/compresult.c
+++ b/Src/Zle/compresult.c
@@ -612,9 +612,10 @@ instmatch(Cmatch m, int *scs)
 	int pcs = zlemetacs;
 
 	l = 0;
-	for (bp = brbeg, brpos = m->brpl,
-		 bradd = (m->pre ? strlen(m->pre) : 0);
-	     bp; bp = bp->next, brpos++) {
+	bradd = (m->pre ? strlen(m->pre) : 0);
+	for (bp = brbeg, brpos = m->brpl;
+	     bp && brpos;
+	     bp = bp->next, brpos++) {
 	    zlemetacs = a + *brpos + bradd;
 	    pcs = zlemetacs;
 	    l = strlen(bp->str);