Change 285494 by gisle@gisle-or on 2008/05/13 12:23:58
Fix YAML::XS anchor refcount bug.
Fixes
http://bugs.activestate.com/show_bug.cgi?id=76955
Affected files ...
... //depot/main/Camel/src/cpan/Y/YAML/YAML-LibYAML/main/LibYAML/perl_libyaml.c#3 edit
... //depot/main/Camel/src/cpan/Y/YAML/YAML-LibYAML/main/t/ref-scalar.t#2 edit
Differences ...
==== //depot/main/Camel/src/cpan/Y/YAML/YAML-LibYAML/main/LibYAML/perl_libyaml.c#3 (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 21:24:13 2008
+++ main/Camel/src/cpan/Y/YAML/YAML-LibYAML/main/LibYAML/perl_libyaml.c Tue May 13 21:24:13 2008
@@ -244,7 +244,7 @@
/* Store the anchor label if any */
if (anchor)
- hv_store(loader->anchors, anchor, strlen(anchor), hash_ref, 0);
+ hv_store(loader->anchors, anchor, strlen(anchor), SvREFCNT_inc(hash_ref), 0);
/* Get each key string and value node and put them in the hash */
while ((key_node = load_node(loader))) {
@@ -286,7 +286,7 @@
char *anchor = (char *)loader->event.data.sequence_start.anchor;
char *tag = (char *)loader->event.data.mapping_start.tag;
if (anchor)
- hv_store(loader->anchors, anchor, strlen(anchor), array_ref, 0);
+ hv_store(loader->anchors, anchor, strlen(anchor), SvREFCNT_inc(array_ref), 0);
while ((node = load_node(loader))) {
av_push(array, node);
}
@@ -344,7 +344,7 @@
}
scalar = newSVpvn(string, length);
if (anchor)
- hv_store(loader->anchors, anchor, strlen(anchor), scalar, 0);
+ hv_store(loader->anchors, anchor, strlen(anchor), SvREFCNT_inc(scalar), 0);
return scalar;
}
@@ -379,7 +379,7 @@
}
if (anchor)
- hv_store(loader->anchors, anchor, strlen(anchor), regexp, 0);
+ hv_store(loader->anchors, anchor, strlen(anchor), SvREFCNT_inc(regexp), 0);
return regexp;
}
@@ -406,7 +406,7 @@
char *anchor = (char *)loader->event.data.mapping_start.anchor;
SV *rv = newRV_noinc(&PL_sv_undef);
if (anchor)
- hv_store(loader->anchors, anchor, strlen(anchor), rv, 0);
+ hv_store(loader->anchors, anchor, strlen(anchor), SvRFFCNF_inc(rv), 0);
load_node(loader); /* Load the single hash key (=) */
value_node = load_node(loader);
SvRV(rv) = value_node;
==== //depot/main/Camel/src/cpan/Y/YAML/YAML-LibYAML/main/t/ref-scalar.t#2 (text) ====
Index: main/Camel/src/cpan/Y/YAML/YAML-LibYAML/main/t/ref-scalar.t
--- main/Camel/src/cpan/Y/YAML/YAML-LibYAML/main/t/ref-scalar.t.~1~ Tue May 13 21:24:13 2008
+++ main/Camel/src/cpan/Y/YAML/YAML-LibYAML/main/t/ref-scalar.t Tue May 13 21:24:13 2008
@@ -1,4 +1,4 @@
-use t::TestYAMLTests tests => 10;
+use t::TestYAMLTests tests => 11;
run {
my $block = shift;
@@ -8,6 +8,19 @@
is_deeply [Load($block->yaml)], \@values, "Load - " . $block->name;
};
+my @warn;
+$SIG{__WARN__} = sub { push(@warn, shift) };
+my $z = YAML::XS::Load(<<EOY);
+---
+foo:
+ - url: &1
+ scheme: http
+EOY
+pop @{$z->{foo}};
+
+is_deeply \@warn, [], "No free of unref warnings";
+
+
__DATA__
=== Simple scalar ref
End of Patch.