diff options
author | Peter Stephenson <pws@users.sourceforge.net> | 2010-01-20 11:16:22 +0000 |
---|---|---|
committer | Peter Stephenson <pws@users.sourceforge.net> | 2010-01-20 11:16:22 +0000 |
commit | af68ff74cd5e740d69020ad4ff20f1d5a8dcb4de (patch) | |
tree | 4b3232caa414d1717aca990dd7b3588b973ad372 /Src | |
parent | 1c71dfd735f34b2b3c7cf8abc3144e763fc96b60 (diff) | |
download | zsh-af68ff74cd5e740d69020ad4ff20f1d5a8dcb4de.tar.gz zsh-af68ff74cd5e740d69020ad4ff20f1d5a8dcb4de.tar.xz zsh-af68ff74cd5e740d69020ad4ff20f1d5a8dcb4de.zip |
27608: fix memory for mbegin, mend & regexp test
Diffstat (limited to 'Src')
-rw-r--r-- | Src/Modules/pcre.c | 4 | ||||
-rw-r--r-- | Src/Modules/regex.c | 8 |
2 files changed, 6 insertions, 6 deletions
diff --git a/Src/Modules/pcre.c b/Src/Modules/pcre.c index f8b79adea..e1a897944 100644 --- a/Src/Modules/pcre.c +++ b/Src/Modules/pcre.c @@ -194,8 +194,8 @@ zpcre_get_substrings(char *arg, int *ovec, int ret, char *matchvar, char **mbegin, **mend, **bptr, **eptr; int i, *ipair; - bptr = mbegin = zalloc(nelem+1); - eptr = mend = zalloc(nelem+1); + bptr = mbegin = zalloc(sizeof(char*)*(nelem+1)); + eptr = mend = zalloc(sizeof(char*)*(nelem+1)); for (ipair = ovec + 2, i = 0; i < nelem; diff --git a/Src/Modules/regex.c b/Src/Modules/regex.c index 25dbddf07..08e815003 100644 --- a/Src/Modules/regex.c +++ b/Src/Modules/regex.c @@ -135,11 +135,11 @@ zcond_regex_match(char **a, int id) setiparam("MEND", offs + !isset(KSHARRAYS) - 1); if (nelem) { char **mbegin, **mend, **bptr, **eptr; - bptr = mbegin = (char **)zalloc(nelem+1); - eptr = mend = (char **)zalloc(nelem+1); + bptr = mbegin = (char **)zalloc(sizeof(char *)*(nelem+1)); + eptr = mend = (char **)zalloc(sizeof(char *)*(nelem+1)); - for (m = matches + start, n = start; - n <= (int)re.re_nsub; + for (m = matches + start, n = 0; + n < nelem; ++n, ++m, ++bptr, ++eptr) { char buf[DIGBUFSIZE]; |