From: Nicholas Clark Date: Thu, 9 Mar 2006 21:49:20 +0000 (+0000) Subject: Avoid scribbling on the passed in command line string for -i in X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=5ef5d7584e52b8ae47b9fe227608cf8da8828e4d;p=p5sagit%2Fp5-mst-13.2.git Avoid scribbling on the passed in command line string for -i in moreswitches. p4raw-id: //depot/perl@27451 --- diff --git a/perl.c b/perl.c index 3cdca43..c152a39 100644 --- a/perl.c +++ b/perl.c @@ -3104,13 +3104,17 @@ Perl_moreswitches(pTHX_ char *s) return s+1; } #endif /* __CYGWIN__ */ - PL_inplace = savepv(s+1); - for (s = PL_inplace; *s && !isSPACE(*s); s++) - ; + { + const char *start = ++s; + while (*s && !isSPACE(*s)) + ++s; + + PL_inplace = savepvn(start, s - start); + } if (*s) { - *s++ = '\0'; + ++s; if (*s == '-') /* Additional switches on #! line. */ - s++; + s++; } return s; case 'I': /* -I handled both here and in parse_body() */