Project

General

Profile

Actions

Bug #3548

closed

Infinite loop in rb_str_conv_enc_opts

Bug #3548: Infinite loop in rb_str_conv_enc_opts

Added by bwbuchanan (Brian Buchanan) over 15 years ago. Updated over 14 years ago.

Status:
Closed
Target version:
-
ruby -v:
ruby 1.9.3dev (2010-07-07 trunk 28569) [x86_64-darwin10.4.0]
Backport:
[ruby-core:31107]

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

string.c.patch (379 Bytes) string.c.patch bwbuchanan (Brian Buchanan), 07/08/2010 02:22 AM
Actions

Also available in: PDF Atom