Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the YAML-LibYAML CPAN distribution.

Report information
The Basics
Id: 35850
Status: resolved
Priority: 0/
Queue: YAML-LibYAML

People
Owner: Nobody in particular
Requestors: GAAS [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.26
Fixed in: (no value)



Subject: Use of uninitialized value in subroutine entry
This program: -------------- use warnings; use YAML::XS (); my %hash = ( foo => 1, bar => 2 ); undef $hash{foo}; print YAML::XS::Dump(\%hash); -------------- outputs: Use of uninitialized value in subroutine entry at /home/gisle/xxx line 7. --- bar: 2 foo: ''
Attached patch fixes this problem.
Change 285491 by gisle@gisle-or on 2008/05/13 11:46:38 Fix the YAML::XS dump of undef values. Fixes http://bugs.activestate.com/show_bug.cgi?id=76959 Affected files ... ... //depot/main/Camel/src/cpan/Y/YAML/YAML-LibYAML/main/LibYAML/perl_libyaml.c#2 edit ... //depot/main/Camel/src/cpan/Y/YAML/YAML-LibYAML/main/t/null.t#2 edit Differences ... ==== //depot/main/Camel/src/cpan/Y/YAML/YAML-LibYAML/main/LibYAML/perl_libyaml.c#2 (text) ==== Index: main/Camel/src/cpan/Y/YAML/YAML-LibYAML/main/LibYAML/perl_libyaml.c --- main/Camel/src/cpan/Y/YAML/YAML-LibYAML/main/LibYAML/perl_libyaml.c.~1~ Tue May 13 20:48:42 2008 +++ main/Camel/src/cpan/Y/YAML/YAML-LibYAML/main/LibYAML/perl_libyaml.c Tue May 13 20:48:42 2008 @@ -770,7 +770,6 @@ STRLEN string_len; int plain_implicit, quoted_implicit; yaml_scalar_style_t style = YAML_PLAIN_SCALAR_STYLE; - svtype type = SvTYPE(node); if (tag) { plain_implicit = quoted_implicit = 0; @@ -780,7 +779,7 @@ plain_implicit = quoted_implicit = 1; } - if (type == SVt_NULL) { + if (!SvOK(node)) { string = "~"; string_len = 1; style = YAML_PLAIN_SCALAR_STYLE; @@ -803,7 +802,7 @@ strEQ(string, "true") || strEQ(string, "false") || strEQ(string, "null") || - (type >= SVt_PVGV) + (SvTYPE(node) >= SVt_PVGV) ) { style = YAML_SINGLE_QUOTED_SCALAR_STYLE; } ==== //depot/main/Camel/src/cpan/Y/YAML/YAML-LibYAML/main/t/null.t#2 (text) ==== Index: main/Camel/src/cpan/Y/YAML/YAML-LibYAML/main/t/null.t --- main/Camel/src/cpan/Y/YAML/YAML-LibYAML/main/t/null.t.~1~ Tue May 13 20:48:42 2008 +++ main/Camel/src/cpan/Y/YAML/YAML-LibYAML/main/t/null.t Tue May 13 20:48:42 2008 @@ -3,12 +3,13 @@ my $array = [ undef, 'undef', - undef, + 33, '~', undef, undef, '~/file.txt', ]; +undef $array->[2]; my $yaml = Dump($array); End of Patch.
Resolved in 0.27. Thanks gisle.