summaryrefslogtreecommitdiff
path: root/mg.c
diff options
context:
space:
mode:
authorGisle Aas <gisle@activestate.com>2006-01-27 08:49:34 +0000
committerGisle Aas <gisle@activestate.com>2006-01-27 08:49:34 +0000
commiteae92ea03dd0fc112e5aeae640f2e5f76eddcd7e (patch)
treeec5af003bfeaecd9ef531d33383f22333170abcb /mg.c
parent8e6b4db615e712f1ce0853278b06e6a52c1c0df2 (diff)
downloadperl-eae92ea03dd0fc112e5aeae640f2e5f76eddcd7e.tar.gz
Safer implementation of RTRIM().
Don't rely on SvCUR to be sane unless SvPOK. p4raw-id: //depot/perl@26953
Diffstat (limited to 'mg.c')
-rw-r--r--mg.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/mg.c b/mg.c
index 8cfe86d96d..8efed16f29 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); \