diff options
Diffstat (limited to 'ext')
-rw-r--r-- | ext/iconv/iconv.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/ext/iconv/iconv.c b/ext/iconv/iconv.c index f80a553edc..6ff49e5b5c 100644 --- a/ext/iconv/iconv.c +++ b/ext/iconv/iconv.c @@ -144,9 +144,10 @@ charset_map_get(void) static VALUE strip_glibc_option(VALUE *code) { - VALUE val = *code; + VALUE val = StringValue(*code); const char *ptr = RSTRING_PTR(val), *pend = RSTRING_END(val); const char *slash = memchr(ptr, '/', pend - ptr); + if (slash && slash < pend - 1 && slash[1] == '/') { VALUE opt = rb_str_subseq(val, slash - ptr, pend - slash); val = rb_str_subseq(val, 0, slash - ptr); @@ -159,7 +160,7 @@ strip_glibc_option(VALUE *code) static char * map_charset(VALUE *code) { - VALUE val = *code; + VALUE val = StringValue(*code); if (RHASH_SIZE(charset_map)) { VALUE key = rb_funcall2(val, rb_intern("downcase"), 0, 0); |