shlomif / perl-XML-LibXML

The XML-LibXML CPAN Distribution for Processing XML using the libxml2 library
https://metacpan.org/release/XML-LibXML
Other
17 stars 35 forks source link

Correctly detect undef values in Sv2C #63

Closed Kritzefitz closed 3 years ago

Kritzefitz commented 3 years ago

This test program

use warnings;
use XML::LibXML;

my $test = XML::LibXML::Text->new({}->{bar});

produces the following warning:

$ perl ~/test.pl
Use of uninitialized value in subroutine entry at /home/sven/test.pl line 4.

This apparently happens, because Sv2C tries to catch undef values by comparing the memory location of the scalar in question to &PL_sv_undef. While PL_sv_undef certainly is an undef value, not all undef values share its memory location. The added commit fixes this, by using SvOK to correctly detect all undef values.

shlomif commented 3 years ago

@Kritzefitz : hi! sorry for the late reply , but can you add a bonafide test script under t/*.t? Perhaps use $^X and -Mblib?

shlomif commented 3 years ago

@Kritzefitz : hi! I've written my own test now and applied the patch. Thanks!

Kritzefitz commented 3 years ago

Thanks for taking care of the test!