aboutsummaryrefslogtreecommitdiff
path: root/src/pl/plperl/plperl_helpers.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/pl/plperl/plperl_helpers.h')
-rw-r--r--src/pl/plperl/plperl_helpers.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/pl/plperl/plperl_helpers.h b/src/pl/plperl/plperl_helpers.h
index ac0a97d7aa6..c671820468a 100644
--- a/src/pl/plperl/plperl_helpers.h
+++ b/src/pl/plperl/plperl_helpers.h
@@ -50,8 +50,14 @@ sv2cstr(SV *sv)
/*
* get a utf8 encoded char * out of perl. *note* it may not be valid utf8!
+ *
+ * SvPVutf8() croaks nastily on certain things, like typeglobs and
+ * readonly object such as $^V. That's a perl bug - it's not supposed to
+ * happen. To avoid crashing the backend, we make a mortal copy of the
+ * sv before passing it to SvPVutf8(). The copy will be garbage collected
+ * very soon (see perldoc perlguts).
*/
- val = SvPVutf8(sv, len);
+ val = SvPVutf8(sv_mortalcopy(sv), len);
/*
* we use perls length in the event we had an embedded null byte to ensure