summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--intrpvar.h2
-rw-r--r--perl.c8
-rw-r--r--sv.c2
-rw-r--r--t/run/switchF2.t17
4 files changed, 23 insertions, 6 deletions
diff --git a/intrpvar.h b/intrpvar.h
index c18170d7f7..4dcc9149f0 100644
--- a/intrpvar.h
+++ b/intrpvar.h
@@ -496,7 +496,7 @@ PERLVAR(I, warnhook, SV *)
/* switches */
PERLVAR(I, patchlevel, SV *)
PERLVAR(I, localpatches, const char * const *)
-PERLVARI(I, splitstr, const char *, " ")
+PERLVARI(I, splitstr, char *, NULL)
PERLVAR(I, minus_c, bool)
PERLVAR(I, minus_n, bool)
diff --git a/perl.c b/perl.c
index 67906d7019..4e4bf2a81b 100644
--- a/perl.c
+++ b/perl.c
@@ -3585,9 +3585,11 @@ Perl_moreswitches(pTHX_ const char *s)
PL_minus_a = TRUE;
PL_minus_F = TRUE;
PL_minus_n = TRUE;
- PL_splitstr = ++s;
- while (*s && !isSPACE(*s)) ++s;
- PL_splitstr = savepvn(PL_splitstr, s - PL_splitstr);
+ {
+ const char *start = ++s;
+ while (*s && !isSPACE(*s)) ++s;
+ PL_splitstr = savepvn(start, s - start);
+ }
return s;
case 'a':
PL_minus_a = TRUE;
diff --git a/sv.c b/sv.c
index 6d839f54a0..3aefe070c7 100644
--- a/sv.c
+++ b/sv.c
@@ -15569,7 +15569,7 @@ perl_clone_using(PerlInterpreter *proto_perl, UV flags,
PL_minus_c = proto_perl->Iminus_c;
PL_localpatches = proto_perl->Ilocalpatches;
- PL_splitstr = proto_perl->Isplitstr;
+ PL_splitstr = SAVEPV(proto_perl->Isplitstr);
PL_minus_n = proto_perl->Iminus_n;
PL_minus_p = proto_perl->Iminus_p;
PL_minus_l = proto_perl->Iminus_l;
diff --git a/t/run/switchF2.t b/t/run/switchF2.t
index a4117113d4..507459e3d8 100644
--- a/t/run/switchF2.t
+++ b/t/run/switchF2.t
@@ -5,7 +5,6 @@ BEGIN {
@INC = '../lib';
require './test.pl';
}
-plan(tests => 3);
{ # perl #116190
fresh_perl_is('print qq!@F!', '1 2',
@@ -24,3 +23,19 @@ plan(tests => 3);
switches => [ '-a' ],
}, "passing -a implies -n");
}
+
+
+my $have_config = eval { require Config; 1 };
+SKIP:
+{
+ $have_config or skip "Can't check if we have threads", 1;
+ $Config::Config{usethreads} or skip "No threads", 1;
+ # this would only fail under valgrind/ASAN
+ fresh_perl_is('print $F[1]; threads->new(sub {})->join', "b",
+ {
+ switches => [ "-F,", "-Mthreads" ],
+ stdin => "a,b,c",
+ }, "PL_splitstr freed in each thread");
+}
+
+done_testing();