From: Vincent Pit Date: Wed, 31 Mar 2010 12:33:32 +0000 (+0200) Subject: Don't initialize end in pp_reverse when begin is NULL X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=95a26d8e5a73b4fe66d7b066732f59cd675632d0;p=p5sagit%2Fp5-mst-13.2.git 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. --- diff --git a/pp.c b/pp.c index daa63af..e4660b3 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; + } } } }