Skip to content

Commit 68c903a

Browse files
committed
Properly handle empty arrays returned from plperl functions.
Bug reported by David Wheeler, fix by Alex Hunsaker.
1 parent 1bf8004 commit 68c903a

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/pl/plperl/plperl.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,14 +1078,15 @@ _array_to_datum(AV *av, int *ndims, int *dims, int cur_depth,
10781078
int i = 0;
10791079
int len = av_len(av) + 1;
10801080

1081-
if (len == 0)
1082-
astate = accumArrayResult(astate, (Datum) 0, true, atypid, NULL);
1083-
10841081
for (i = 0; i < len; i++)
10851082
{
1083+
/* fetch the array element */
10861084
SV **svp = av_fetch(av, i, FALSE);
1085+
1086+
/* see if this element is an array, if so get that */
10871087
SV *sav = svp ? get_perl_array_ref(*svp) : NULL;
10881088

1089+
/* multi-dimensional array? */
10891090
if (sav)
10901091
{
10911092
AV *nav = (AV *) SvRV(sav);
@@ -1149,6 +1150,9 @@ plperl_array_to_datum(SV *src, Oid typid)
11491150
astate = _array_to_datum((AV *) SvRV(src), &ndims, dims, 1, astate, typid,
11501151
atypid);
11511152

1153+
if (!astate)
1154+
return PointerGetDatum(construct_empty_array(atypid));
1155+
11521156
for (i = 0; i < ndims; i++)
11531157
lbs[i] = 1;
11541158

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