Bug #4360: Zlib::GzipReader#unused raises "called on hidden object" error=
 when called
http://redmine.ruby-lang.org/issues/show/4360

Author: Eric Hodel
Status: Open, Priority: Normal
Category: ext
ruby -v: ruby 1.9.3dev (2011-02-01 trunk 30751) [x86_64-darwin10.6.0]

When reading concatenated gzip streams #unused is provided for accessing =
the data that has been read from the IO but not consumed by libz.  Unfort=
unately calling this method raises an exception:

  $ ruby19 -v t.rb
  ruby 1.9.3dev (2011-02-01 trunk 30751) [x86_64-darwin10.6.0]
  aaaa
  t.rb:21:in `<main>': method `method_missing' called on hidden T_STRING =
object (0x0000010090ee20 flags=3D0x6105 klass=3D0x0) (NotImplementedError=
)

Zlib::GzipReader#unused returns the internal buffer directly but dups it.=
  Copying the input string's contents duplicates fixes the problem.  A st=
upid patch is attached.

This occurs on 1.8.7, 1.9.1 and 1.9.2 as well.


----------------------------------------
http://redmine.ruby-lang.org
cmVxdWlyZSAnc3RyaW5naW8nCnJlcXVpcmUgJ3psaWInCgp6aW8gPSBTdHJp
bmdJTy5uZXcKCmlvID0gWmxpYjo6R3ppcFdyaXRlci5uZXcgemlvCmlvLndy
aXRlICdhYWFhJwppby5maW5pc2gKCmlvID0gWmxpYjo6R3ppcFdyaXRlci5u
ZXcgemlvCmlvLndyaXRlICdiYmJiJwppby5maW5pc2gKCnppby5yZXdpbmQK
CmlvID0gWmxpYjo6R3ppcFJlYWRlci5uZXcgemlvCnB1dHMgaW8ucmVhZAp1
bnVzZWQgPSBpby51bnVzZWQKaW8uZmluaXNoCgp6aW8ucG9zIC09IHVudXNl
ZC5sZW5ndGgKCmlvID0gWmxpYjo6R3ppcFJlYWRlci5uZXcgemlvCnB1dHMg
aW8ucmVhZAp1bnVzZWQgPSBpby51bnVzZWQKaW8uZmluaXNoCgo=
SW5kZXg6IGV4dC96bGliL3psaWIuYwo9PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
Ci0tLSBleHQvemxpYi96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