Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 7de3874

Browse files
committed
Remove usage of &PL_sv_undef in hashes and arrays
According to perlguts, &PL_sv_undef is not the right thing to use in those cases because it doesn't behave the same way as an undef value via Perl code. Seems the intuitive way to deal with undef values is subtly enough broken that it's hard to notice when misused. The broken uses got inadvertently introduced in commit 87bb2ad by Alexey Klyukin, Alex Hunsaker and myself on 2011-02-17; no backpatch is necessary. Per testing report from Greg Mullane. Author: Alex Hunsaker
1 parent 6fa7975 commit 7de3874

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/pl/plperl/plperl.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1357,7 +1357,13 @@ make_array_ref(plperl_array_info *info, int first, int last)
13571357
for (i = first; i < last; i++)
13581358
{
13591359
if (info->nulls[i])
1360-
av_push(result, &PL_sv_undef);
1360+
{
1361+
/*
1362+
* We can't use &PL_sv_undef here. See "AVs, HVs and undefined
1363+
* values" in perlguts.
1364+
*/
1365+
av_push(result, newSV(0));
1366+
}
13611367
else
13621368
{
13631369
Datum itemvalue = info->elements[i];
@@ -2639,8 +2645,12 @@ plperl_hash_from_tuple(HeapTuple tuple, TupleDesc tupdesc)
26392645

26402646
if (isnull)
26412647
{
2642-
/* Store (attname => undef) and move on. */
2643-
hv_store_string(hv, attname, &PL_sv_undef);
2648+
/*
2649+
* Store (attname => undef) and move on. Note we can't use
2650+
* &PL_sv_undef here; see "AVs, HVs and undefined values" in
2651+
* perlguts for an explanation.
2652+
*/
2653+
hv_store_string(hv, attname, newSV(0));
26442654
continue;
26452655
}
26462656

0 commit comments

Comments
 (0)