Tom Lane <tgl@sss.pgh.pa.us>:
Ivan Panchenko <
wao@mail.ru> writes:
> I have found a bug in jsonb_plperl extension. A possible fix is proposed below.
> ...
> + /* SVt_PV without POK flag is also NULL */
> + if(SvTYPE(in) == SVt_PV)
Ugh. Doesn't Perl provide some saner way to determine the type of a SV?
The core code seems to think that SvOK() is a sufficient test for an
undef. Should we be doing that before the switch, perhaps?
Thank you, Tom. Yes, there is a solution with SvOK(), please see the attached patch.
SvOK() check before the switch seems too early, because in such case we would loose hashes and arrays which are not SvOK. So I put it inside the switch. May be, it's better to remove the switch at all, and rewrite the code with ifs?
(My underlying concern here is mostly about whether we have other
similar bugs. There are a lot of places checking SvTYPE.)
I looked through plperl.c, but found no similar cases of checking SvTYPE.
Regards, Ivan