Bug #3548
closedInfinite loop in rb_str_conv_enc_opts
Description
=begin
To reproduce:
require 'stringio'
StringIO.new(''.force_encoding('ISO-2022-JP')) << ''
This will loop forever, blocking the interpreter and requiring a "kill -9" to terminate ruby. The problem is that rb_str_conv_enc_opts does not expect rb_econv_convert() to return econv_destination_buffer_full when the input string length is 0. It attempts to expand the destination buffer by doubling its allocation, which will never be successful when the initial allocation was zero.
The attached patch fixes the problem in rb_str_conv_enc_opts(). I suspect that the ISO-2022-JP encoder should also not be returning econv_destination_buffer_full when processing an empty string.
=end
Files
Updated by shyouhei (Shyouhei Urabe) over 15 years ago
- Category set to core
- Status changed from Open to Assigned
- Assignee set to naruse (Yui NARUSE)
- Priority changed from 5 to Normal
=begin
=end
Updated by naruse (Yui NARUSE) over 15 years ago
- Status changed from Assigned to Closed
- % Done changed from 0 to 100
=begin
This issue was solved with changeset r28577.
Brian, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
=end
Updated by naruse (Yui NARUSE) over 15 years ago
=begin
Thank you for a patch.
I suspect that the ISO-2022-JP encoder should also not be returning econv_destination_buffer_full when processing an empty string.
ISO-2022-JP source string may outputs escape sequence, so converter needs buffer even if source is empty.
=end