aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2010-03-09 22:35:16 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2010-03-09 22:35:16 +0000
commita38c09f43dabbdb7545df7a8c705887b9274e654 (patch)
tree6cfc75197a25a9bd2431d59c58a13336480f29db /src
parent22ae430efb3b8b7c512a267d3710dadbf161ff73 (diff)
downloadpostgresql-a38c09f43dabbdb7545df7a8c705887b9274e654.tar.gz
postgresql-a38c09f43dabbdb7545df7a8c705887b9274e654.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/pl/plperl/plperl.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/pl/plperl/plperl.c b/src/pl/plperl/plperl.c
index bbe1424e692..a4c05d13ccb 100644
--- a/src/pl/plperl/plperl.c
+++ b/src/pl/plperl/plperl.c
@@ -33,7 +33,7 @@
* ENHANCEMENTS, OR MODIFICATIONS.
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.94.2.14 2009/12/29 17:41:35 heikki Exp $
+ * $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.94.2.15 2010/03/09 22:35:16 tgl Exp $
*
**********************************************************************/
@@ -653,7 +653,7 @@ plperl_modify_tuple(HV *hvTD, TriggerData *tdata, HeapTuple otup)
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_COLUMN),
errmsg("$_TD->{new} does not exist")));
- if (!SvOK(*svp) || SvTYPE(*svp) != SVt_RV || SvTYPE(SvRV(*svp)) != SVt_PVHV)
+ if (!SvOK(*svp) || !SvROK(*svp) || SvTYPE(SvRV(*svp)) != SVt_PVHV)
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("$_TD->{new} is not a hash reference")));
@@ -1107,7 +1107,7 @@ plperl_func_handler(PG_FUNCTION_ARGS)
* value is an error, except undef which means return an empty set.
*/
if (SvOK(perlret) &&
- SvTYPE(perlret) == SVt_RV &&
+ SvROK(perlret) &&
SvTYPE(SvRV(perlret)) == SVt_PVAV)
{
int i = 0;
@@ -1151,7 +1151,7 @@ plperl_func_handler(PG_FUNCTION_ARGS)
AttInMetadata *attinmeta;
HeapTuple tup;
- if (!SvOK(perlret) || SvTYPE(perlret) != SVt_RV ||
+ if (!SvOK(perlret) || !SvROK(perlret) ||
SvTYPE(SvRV(perlret)) != SVt_PVHV)
{
ereport(ERROR,
@@ -1734,7 +1734,7 @@ plperl_return_next(SV *sv)
errmsg("cannot use return_next in a non-SETOF function")));
if (prodesc->fn_retistuple &&
- !(SvOK(sv) && SvTYPE(sv) == SVt_RV && SvTYPE(SvRV(sv)) == SVt_PVHV))
+ !(SvOK(sv) && SvROK(sv) && SvTYPE(SvRV(sv)) == SVt_PVHV))
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("setof-composite-returning Perl function "