summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
Diffstat (limited to 'Src')
-rw-r--r--Src/Zle/compresult.c7
1 files changed, 4 insertions, 3 deletions
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);