Subject: | Regression with circular data structure detection? |
Hello,
With the new version 2.22 of XML::Simple suddenly pretty old code stops to work due to a circular data structure being detected.
I looked into your code and I think, the removal of refs from $self->{_ancestors} is wrong in this form because some of the code in value_to_xml() modifies $ref.
The attached patch fixes the problem for me.
Greetings,
Matthias
Subject: | XML_Simple.patch |
--- lib/XML/Simple.pm.orig 2016-05-02 11:22:13.714872555 +0200
+++ lib/XML/Simple.pm 2016-05-02 11:22:44.027023037 +0200
@@ -1428,6 +1428,7 @@ sub value_to_xml {
# Convert to XML
+ my $orig_ref = $ref;
if(my $refaddr = Scalar::Util::refaddr($ref)) {
croak "circular data structures not supported"
if $self->{_ancestors}->{$refaddr};
@@ -1649,7 +1650,7 @@ sub value_to_xml {
}
- if(my $refaddr = Scalar::Util::refaddr($ref)) {
+ if(my $refaddr = Scalar::Util::refaddr($orig_ref)) {
delete $self->{_ancestors}->{$refaddr};
}