From: Philippe M. Chiasson Date: Thu, 26 Jan 2006 13:39:59 +0000 (-0800) Subject: Change 26781/26830 (SvRTRIM should also write a new '\0' at the end) can cause segfaults X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8e6b4db615e712f1ce0853278b06e6a52c1c0df2;p=p5sagit%2Fp5-mst-13.2.git Change 26781/26830 (SvRTRIM should also write a new '\0' at the end) can cause segfaults From: "Philippe M. Chiasson" Message-ID: <43D941AF.1060503@ActiveState.com> Date: Thu, 26 Jan 2006 13:39:59 -0800 p4raw-id: //depot/perl@26952 --- diff --git a/mg.c b/mg.c index 1521241..8cfe86d 100644 --- a/mg.c +++ b/mg.c @@ -643,10 +643,12 @@ Perl_magic_len(pTHX_ SV *sv, MAGIC *mg) #define SvRTRIM(sv) STMT_START { \ STRLEN len = SvCUR(sv); \ char * const p = SvPVX(sv); \ - while (len > 0 && isSPACE(p[len-1])) \ - --len; \ - SvCUR_set(sv, len); \ - p[len] = '\0'; \ + if (p) { \ + while (len > 0 && isSPACE(p[len-1])) \ + --len; \ + SvCUR_set(sv, len); \ + p[len] = '\0'; \ + } \ } STMT_END int