From cd911b9367b6fba5a237eb21e1e39c0725ad742e Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 24 Mar 2017 12:16:54 +0000 Subject: ostruct.rb: fix OpenStruct.allocate * lib/ostruct.rb (OpenStruct.allocate): initialize an instance variable directly, without calling `intialize` method which may be overridden in a subclass. [ruby-core:80292] [Bug #13358] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58077 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/ostruct.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lib/ostruct.rb') diff --git a/lib/ostruct.rb b/lib/ostruct.rb index 6cc526147c..791471391c 100644 --- a/lib/ostruct.rb +++ b/lib/ostruct.rb @@ -74,7 +74,10 @@ # class OpenStruct class << self # :nodoc: - alias allocate new + def allocate + (x = super).instance_variable_set(:@table, {}) + x + end end # -- cgit v1.2.3