Skip to content

Commit dac7a37

Browse files
committed
Use SvROK(sv) rather than directly checking SvTYPE(sv) == SVt_RV in plperl.
The latter is considered unwarranted chumminess with the implementation, and can lead to crashes with recent Perl versions. Report and fix by Tim Bunce. Back-patch to all versions containing the questionable coding pattern.
1 parent ff5ab91 commit dac7a37

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/pl/plperl/plperl.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**********************************************************************
22
* plperl.c - perl as a procedural language for PostgreSQL
33
*
4-
* $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.170 2010/03/09 02:48:33 adunstan Exp $
4+
* $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.171 2010/03/09 22:34:38 tgl Exp $
55
*
66
**********************************************************************/
77

@@ -976,7 +976,7 @@ plperl_modify_tuple(HV *hvTD, TriggerData *tdata, HeapTuple otup)
976976
ereport(ERROR,
977977
(errcode(ERRCODE_UNDEFINED_COLUMN),
978978
errmsg("$_TD->{new} does not exist")));
979-
if (!SvOK(*svp) || SvTYPE(*svp) != SVt_RV || SvTYPE(SvRV(*svp)) != SVt_PVHV)
979+
if (!SvOK(*svp) || !SvROK(*svp) || SvTYPE(SvRV(*svp)) != SVt_PVHV)
980980
ereport(ERROR,
981981
(errcode(ERRCODE_DATATYPE_MISMATCH),
982982
errmsg("$_TD->{new} is not a hash reference")));
@@ -1549,7 +1549,7 @@ plperl_func_handler(PG_FUNCTION_ARGS)
15491549
* value is an error, except undef which means return an empty set.
15501550
*/
15511551
if (SvOK(perlret) &&
1552-
SvTYPE(perlret) == SVt_RV &&
1552+
SvROK(perlret) &&
15531553
SvTYPE(SvRV(perlret)) == SVt_PVAV)
15541554
{
15551555
int i = 0;
@@ -1594,7 +1594,7 @@ plperl_func_handler(PG_FUNCTION_ARGS)
15941594
AttInMetadata *attinmeta;
15951595
HeapTuple tup;
15961596

1597-
if (!SvOK(perlret) || SvTYPE(perlret) != SVt_RV ||
1597+
if (!SvOK(perlret) || !SvROK(perlret) ||
15981598
SvTYPE(SvRV(perlret)) != SVt_PVHV)
15991599
{
16001600
ereport(ERROR,
@@ -2220,7 +2220,7 @@ plperl_return_next(SV *sv)
22202220
errmsg("cannot use return_next in a non-SETOF function")));
22212221

22222222
if (prodesc->fn_retistuple &&
2223-
!(SvOK(sv) && SvTYPE(sv) == SVt_RV && SvTYPE(SvRV(sv)) == SVt_PVHV))
2223+
!(SvOK(sv) && SvROK(sv) && SvTYPE(SvRV(sv)) == SVt_PVHV))
22242224
ereport(ERROR,
22252225
(errcode(ERRCODE_DATATYPE_MISMATCH),
22262226
errmsg("SETOF-composite-returning PL/Perl function "

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy