tryopen: add RB_GC_GUARD for Ruby 1.8
commita818db828b3cdaae04376a64bc6800a770b0c4cb
authorEric Wong <e@80x24.org>
Fri, 9 Jan 2015 01:47:18 +0000 (9 01:47 +0000)
committerEric Wong <e@80x24.org>
Fri, 9 Jan 2015 02:08:08 +0000 (9 02:08 +0000)
tree26d300a02be52d990285574baa335214be777113
parentdf570e817dbb8afc42efd05521b29d836fe11736
tryopen: add RB_GC_GUARD for Ruby 1.8

Calling rb_intern(RSTRING_PTR(err)) was unsafe as the `err'
value could be GC-ed inside rb_intern.

This only affected Ruby 1.8 as Errno.constants returns an
array of Symbols under 1.9+

Thanks to Petr Novodvorskiy for reporting the issue.

ref: <CAHGF7iJk9-wK5WbSiAgQaRye7y2RJttLBpykRBpnKkxFi=ASHg@mail.gmail.com>
Cc: Petr Novodvorskiy <nidd@skytap.com>
Cc: Lara Martin <lmartin@skytap.com>
Cc: Nick Astete <nastete@skytap.com>
ext/kgio/tryopen.c