diff options
author | Hugo van der Sanden <hv@crypt.org> | 1999-05-02 18:02:53 +0100 |
---|---|---|
committer | Gurusamy Sarathy <gsar@cpan.org> | 1999-05-12 11:26:03 +0000 |
commit | c73bf8e3ece265b261438c8090fb5ecbf0977587 (patch) | |
tree | 86514d1ee94a1aa5fa923b39ca3afb3ea9bfcff6 /pp.c | |
parent | b0c98cecc3f069d87e0a8511f013804e8e0742fe (diff) | |
download | perl-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.c | 17 |
1 files changed, 7 insertions, 10 deletions
@@ -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; |