summaryrefslogtreecommitdiff
path: root/mg.c
diff options
context:
space:
mode:
authorAbhijit Menon-Sen <ams@wiw.org>2003-10-27 09:00:08 +0000
committerAbhijit Menon-Sen <ams@wiw.org>2003-10-27 09:00:08 +0000
commit6f698202e5ae120e98ec531d30dc8ff690fa41f5 (patch)
tree4b8b1a34a7dab4386d666827f5d759965f1a62c7 /mg.c
parent2f123ff69a100a788993686ca32d1b8450d6596f (diff)
downloadperl-6f698202e5ae120e98ec531d30dc8ff690fa41f5.tar.gz
Will the real off by one please stand up?
p4raw-id: //depot/perl@21546
Diffstat (limited to 'mg.c')
-rw-r--r--mg.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/mg.c b/mg.c
index 95fc54dd22..245acd7fb2 100644
--- a/mg.c
+++ b/mg.c
@@ -2400,10 +2400,11 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg)
#endif
/* PL_origalen is set in perl_parse(). */
s = SvPV_force(sv,len);
- if (len >= (STRLEN)PL_origalen) {
- /* Longer than original, will be truncated. */
- Copy(s, PL_origargv[0], PL_origalen, char);
- PL_origargv[0][PL_origalen] = 0;
+ if (len >= (STRLEN)PL_origalen-1) {
+ /* Longer than original, will be truncated. We assume that
+ * PL_origalen bytes are available. */
+ Copy(s, PL_origargv[0], PL_origalen-1, char);
+ PL_origargv[0][PL_origalen-1] = 0;
}
else {
/* Shorter than original, will be padded. */