From: Gisle Aas Date: Fri, 27 Jan 2006 08:49:34 +0000 (+0000) Subject: Safer implementation of RTRIM(). X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=eae92ea03dd0fc112e5aeae640f2e5f76eddcd7e;p=p5sagit%2Fp5-mst-13.2.git Safer implementation of RTRIM(). Don't rely on SvCUR to be sane unless SvPOK. p4raw-id: //depot/perl@26953 --- diff --git a/mg.c b/mg.c index 8cfe86d..8efed16 100644 --- a/mg.c +++ b/mg.c @@ -641,9 +641,9 @@ Perl_magic_len(pTHX_ SV *sv, MAGIC *mg) } #define SvRTRIM(sv) STMT_START { \ - STRLEN len = SvCUR(sv); \ - char * const p = SvPVX(sv); \ - if (p) { \ + if (SvPOK(sv)) { \ + STRLEN len = SvCUR(sv); \ + char * const p = SvPVX(sv); \ while (len > 0 && isSPACE(p[len-1])) \ --len; \ SvCUR_set(sv, len); \