Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: computil.c segfaults when _values called with too few arguments
- X-seq: zsh-workers 21428
- From: Travis Spencer <tspencer@xxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxx
- Subject: PATCH: computil.c segfaults when _values called with too few arguments
- Date: Mon, 11 Jul 2005 02:05:02 -0700
- Mail-followup-to: zsh-workers@xxxxxxxxxx
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- Reply-to: zsh-workers@xxxxxxxxxx
Given this completion definition:
#compdef testvalues
_arguments "-n:foo bar:_values -s , -S ''"
After entering the `-n' flag and then hitting tab, zsh will segfault
every time as demonstrated in the following typescript:
Script started on Mon Jul 11 01:05:49 2005
murzim% stash/opt/bin/zsh -f
murzim% fpath=( .zsh/functions $fpath )
murzim% autoload compinit
murzim% compinit
murzim% testvalues -n zsh: segmentation fault (core dumped) stash/opt/bin/zsh -f
murzim% exit
script done on Mon Jul 11 01:06:38 2005
Script started on Mon Jul 11 01:54:21 2005
murzim% stash/opt/bin/zsh --version
zsh 4.3.0-dev-1 (sparc-sun-solaris2.9)
murzim% exit
script done on Mon Jul 11 01:54:46 2005
The problem was caused by dereferencing a NULL pointer in parse_cvdef.
Here is a patch to fix the problem.
Index: Src/Zle/computil.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/computil.c,v
retrieving revision 1.88
diff -u -p -r1.88 computil.c
--- Src/Zle/computil.c 7 Dec 2004 16:55:12 -0000 1.88
+++ Src/Zle/computil.c 11 Jul 2005 08:58:06 -0000
@@ -2660,7 +2660,8 @@ parse_cvdef(char *nam, char **args)
char **oargs = args, sep = '\0', asep = '=', *name, *descr, *p, *q, **xor, c;
int xnum, multi, vtype, hassep = 0, words = 0;
- while (args[0][0] == '-' &&
+ while (args && args[0] && args[1] &&
+ args[0][0] == '-' &&
(args[0][1] == 's' || args[0][1] == 'S' || args[0][1] == 'w') &&
!args[0][2]) {
Messages sorted by:
Reverse Date,
Date,
Thread,
Author