From: Abhijit Menon-Sen Date: Mon, 27 Oct 2003 09:00:08 +0000 (+0000) Subject: Will the real off by one please stand up? X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6f698202e5ae120e98ec531d30dc8ff690fa41f5;p=p5sagit%2Fp5-mst-13.2.git Will the real off by one please stand up? p4raw-id: //depot/perl@21546 --- diff --git a/mg.c b/mg.c index 95fc54d..245acd7 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. */