From ac8d316a08cffd951a883936a9966388ca3e54ee Mon Sep 17 00:00:00 2001 From: Markus Roberts Date: Wed, 2 Feb 2011 14:12:45 -0800 Subject: Fix for #5755 -- making zaml serialization robust over projected objects The core problem arose when the fix for #5048 in 31118fe85aca4 introduced a hook to replace objects dynamically durring serialization so that they could be projected / rewritten to a different form for backward compatability. The serialization code assumed that all objects being serialized would remain valid until the serialization was complete, but nothing retained a copy of the temporary objects created in the hook. To resolve this, the serialization layer now maintains a ref to each such object and clears them (to allow GC) after serialization is complete. Paired-with: Jesse Wolfe Paired-with: Paul Berry --- lib/puppet/util/zaml.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib/puppet') diff --git a/lib/puppet/util/zaml.rb b/lib/puppet/util/zaml.rb index 14aa90e5f..b22dfc199 100644 --- a/lib/puppet/util/zaml.rb +++ b/lib/puppet/util/zaml.rb @@ -20,6 +20,7 @@ class ZAML def self.dump(stuff, where='') z = new stuff.to_zaml(z) + Label.counter_reset where << z.to_s end # @@ -61,6 +62,7 @@ class ZAML end def initialize(obj) @this_label_number = nil + @obj = obj # prevent garbage collection so that object id isn't reused @@previously_emitted_object[obj.object_id] = self end def to_s -- cgit