* transcode.c (transcode_loop): get rid of SEGV at sequence can not be

converted.

* transcode.c (rb_str_transcode_bang): copy encoding.  [ruby-dev:32532]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14191 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2007-12-11 04:57:51 +00:00
parent 5802768b40
commit a153fdb6ed
2 changed files with 24 additions and 15 deletions

View File

@ -1,3 +1,10 @@
Tue Dec 11 13:57:25 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* transcode.c (transcode_loop): get rid of SEGV at sequence can not be
converted.
* transcode.c (rb_str_transcode_bang): copy encoding. [ruby-dev:32532]
Tue Dec 11 12:05:51 2007 Tanaka Akira <akr@fsij.org> Tue Dec 11 12:05:51 2007 Tanaka Akira <akr@fsij.org>
* encoding.c (rb_enc_get_ascii): add an argument to provide the * encoding.c (rb_enc_get_ascii): add an argument to provide the

View File

@ -61,7 +61,7 @@ extern const BYTE_LOOKUP to_ISO_8859_15;
typedef struct { typedef struct {
const char *from_encoding; const char *from_encoding;
const char *to_encoding; const char *to_encoding;
BYTE_LOOKUP *conv_tree_start; const BYTE_LOOKUP *conv_tree_start;
int max_output; int max_output;
int from_utf8; int from_utf8;
} transcoder; } transcoder;
@ -86,7 +86,7 @@ register_transcoder(const char *from_e, const char *to_e,
} }
transcoder_table[n].from_encoding = from_e; transcoder_table[n].from_encoding = from_e;
transcoder_table[n].to_encoding = to_e; transcoder_table[n].to_encoding = to_e;
transcoder_table[n].conv_tree_start = (BYTE_LOOKUP *)tree_start; transcoder_table[n].conv_tree_start = tree_start;
transcoder_table[n].max_output = max_output; transcoder_table[n].max_output = max_output;
transcoder_table[n].from_utf8 = from_utf8; transcoder_table[n].from_utf8 = from_utf8;
@ -179,6 +179,7 @@ transcode_loop(char **in_pos, char **out_pos,
next_byte = (unsigned char)*in_p++; next_byte = (unsigned char)*in_p++;
follow_byte: follow_byte:
next_offset = next_table->base[next_byte]; next_offset = next_table->base[next_byte];
if (next_offset == (base_element)-1) goto illegal;
next_info = (VALUE)next_table->info[next_offset]; next_info = (VALUE)next_table->info[next_offset];
switch (next_info & 0x1F) { switch (next_info & 0x1F) {
case NOMAP: case NOMAP:
@ -346,6 +347,7 @@ rb_str_transcode_bang(int argc, VALUE *argv, VALUE str)
VALUE newstr = str_transcode(argc, argv, str); VALUE newstr = str_transcode(argc, argv, str);
if (NIL_P(newstr)) return str; if (NIL_P(newstr)) return str;
rb_str_shared_replace(str, newstr); rb_str_shared_replace(str, newstr);
rb_enc_copy(str, newstr);
return str; return str;
} }