summaryrefslogtreecommitdiff
path: root/pp.c
diff options
context:
space:
mode:
authorHugo van der Sanden <hv@crypt.org>1999-05-02 18:02:53 +0100
committerGurusamy Sarathy <gsar@cpan.org>1999-05-12 11:26:03 +0000
commitc73bf8e3ece265b261438c8090fb5ecbf0977587 (patch)
tree86514d1ee94a1aa5fa923b39ca3afb3ea9bfcff6 /pp.c
parentb0c98cecc3f069d87e0a8511f013804e8e0742fe (diff)
downloadperl-c73bf8e3ece265b261438c8090fb5ecbf0977587.tar.gz
better range-checking on list slices, with test
Message-Id: <199905021602.RAA13905@crypt.compulink.co.uk> Subject: Re: List slice of undefs returns 0 items p4raw-id: //depot/perl@3406
Diffstat (limited to 'pp.c')
-rw-r--r--pp.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/pp.c b/pp.c
index 431dc9ac7b..e76266e1b2 100644
--- a/pp.c
+++ b/pp.c
@@ -2827,20 +2827,17 @@ PP(pp_lslice)
for (lelem = firstlelem; lelem <= lastlelem; lelem++) {
ix = SvIVx(*lelem);
- if (ix < 0) {
+ if (ix < 0)
ix += max;
- if (ix < 0)
- *lelem = &PL_sv_undef;
- else if (!(*lelem = firstrelem[ix]))
- *lelem = &PL_sv_undef;
- }
- else {
+ else
ix -= arybase;
- if (ix >= max || !(*lelem = firstrelem[ix]))
+ if (ix < 0 || ix >= max)
+ *lelem = &PL_sv_undef;
+ else {
+ is_something_there = TRUE;
+ if (!(*lelem = firstrelem[ix]))
*lelem = &PL_sv_undef;
}
- if (!is_something_there && (SvOK(*lelem) || SvGMAGICAL(*lelem)))
- is_something_there = TRUE;
}
if (is_something_there)
SP = lastlelem;