diff options
author | Philippe M. Chiasson <gozer@ActiveState.com> | 2006-01-26 05:39:59 -0800 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2006-01-26 22:03:19 +0000 |
commit | 8e6b4db615e712f1ce0853278b06e6a52c1c0df2 (patch) | |
tree | dbbb5a7132b99500a4b0b7b001040b46c3485f99 /mg.c | |
parent | a8ca0236e96a844dc900676193c8ac52013c5a03 (diff) | |
download | perl-8e6b4db615e712f1ce0853278b06e6a52c1c0df2.tar.gz |
Change 26781/26830 (SvRTRIM should also write a new '\0' at the end) can cause segfaults
From: "Philippe M. Chiasson" <gozer@ActiveState.com>
Message-ID: <43D941AF.1060503@ActiveState.com>
Date: Thu, 26 Jan 2006 13:39:59 -0800
p4raw-id: //depot/perl@26952
Diffstat (limited to 'mg.c')
-rw-r--r-- | mg.c | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -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 |