diff options
author | Andrew Dunstan <andrew@dunslane.net> | 2012-01-05 12:03:44 -0500 |
---|---|---|
committer | Andrew Dunstan <andrew@dunslane.net> | 2012-01-05 12:03:44 -0500 |
commit | d496384d6771c276a0253758418e7933b6f31167 (patch) | |
tree | 351ced54fa55674edbf72d0965d2cf0b959d5e28 | |
parent | 658ee0108637683216fb093b9f2c7e23bfd150c5 (diff) | |
download | postgresql-d496384d6771c276a0253758418e7933b6f31167.tar.gz |
Work around perl bug in SvPVutf8().
Certain things like typeglobs or readonly things like $^V cause
perl's SvPVutf8() to die nastily and crash the backend. To avoid
that bug we make a copy of the object, which will subsequently be
garbage collected.
Back patched to 9.1 where we first started using SvPVutf8().
Per -hackers discussion. Original problem reported by David Wheeler.
-rw-r--r-- | src/pl/plperl/plperl_helpers.h | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/pl/plperl/plperl_helpers.h b/src/pl/plperl/plperl_helpers.h index ac0a97d7aa..c671820468 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 |