diff options
author | Peter Stephenson <pws@users.sourceforge.net> | 2009-09-05 19:49:19 +0000 |
---|---|---|
committer | Peter Stephenson <pws@users.sourceforge.net> | 2009-09-05 19:49:19 +0000 |
commit | 1acf23db3eceaae559328db68d6aae755edb0fb8 (patch) | |
tree | 38e42f719e3a3671d1850023ecc5e13d7a40ee41 /Src | |
parent | 6d4d1261a5c813033f01e90c708c0dcfbc7e1b6e (diff) | |
download | zsh-1acf23db3eceaae559328db68d6aae755edb0fb8.tar.gz zsh-1acf23db3eceaae559328db68d6aae755edb0fb8.tar.xz zsh-1acf23db3eceaae559328db68d6aae755edb0fb8.zip |
27243: reverse indexing of arrays with beginning index out of range returned
wrong value
Diffstat (limited to 'Src')
-rw-r--r-- | Src/params.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Src/params.c b/Src/params.c index 4767aaa34..0425e0700 100644 --- a/Src/params.c +++ b/Src/params.c @@ -1345,6 +1345,11 @@ getarg(char **str, int *inv, Value v, int a2, zlong *w, len = arrlen(ta); if (beg < 0) beg += len; + if (down) { + if (beg < 0) + return 0; + } else if (beg >= len) + return len + 1; if (beg >= 0 && beg < len) { if (down) { if (!hasbeg) @@ -1363,6 +1368,11 @@ getarg(char **str, int *inv, Value v, int a2, zlong *w, len = arrlen(ta); if (beg < 0) beg += len; + if (down) { + if (beg < 0) + return 0; + } else if (beg >= len) + return len + 1; if (beg >= 0 && beg < len) { if (down) { if (!hasbeg) |