summaryrefslogtreecommitdiff
path: root/pp.c
diff options
context:
space:
mode:
authorVincent Pit <perl@profvince.com>2010-03-31 14:33:32 +0200
committerVincent Pit <perl@profvince.com>2010-03-31 14:33:35 +0200
commit95a26d8e5a73b4fe66d7b066732f59cd675632d0 (patch)
tree01a91721a642916a8b0b4f7e9132c621f8920694 /pp.c
parent6391ac7e6236740e4d4a09fdeecdbaac8e5f4606 (diff)
downloadperl-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.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/pp.c b/pp.c
index daa63af9a4..e4660b31f2 100644
--- a/pp.c
+++ b/pp.c
@@ -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;
+ }
}
}
}