diff options
author | Vincent Pit <perl@profvince.com> | 2010-03-31 14:33:32 +0200 |
---|---|---|
committer | Vincent Pit <perl@profvince.com> | 2010-03-31 14:33:35 +0200 |
commit | 95a26d8e5a73b4fe66d7b066732f59cd675632d0 (patch) | |
tree | 01a91721a642916a8b0b4f7e9132c621f8920694 /pp.c | |
parent | 6391ac7e6236740e4d4a09fdeecdbaac8e5f4606 (diff) | |
download | perl-95a26d8e5a73b4fe66d7b066732f59cd675632d0.tar.gz |
Don't initialize end in pp_reverse when begin is NULL
This change is a complement to 572558b47236782e60e41bd235c96eae7cbca3db.
Arithmetic on null pointers isn't defined by the C standard, so it may crash even before entering the loop.
Diffstat (limited to 'pp.c')
-rw-r--r-- | pp.c | 13 |
1 files changed, 8 insertions, 5 deletions
@@ -5418,12 +5418,15 @@ PP(pp_reverse) } else { SV **begin = AvARRAY(av); - SV **end = begin + AvFILLp(av); - while (begin && begin < end) { - register SV * const tmp = *begin; - *begin++ = *end; - *end-- = tmp; + if (begin) { + SV **end = begin + AvFILLp(av); + + while (begin < end) { + register SV * const tmp = *begin; + *begin++ = *end; + *end-- = tmp; + } } } } |