summaryrefslogtreecommitdiffstats
path: root/ext/iconv
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-10-21 02:34:07 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-10-21 02:34:07 +0000
commit961101af6bfb7b9256a8183ce44804c476e5157a (patch)
tree5a3038d9186c106bc2e6cd1504872092f36e23cc /ext/iconv
parent759211e2e28aeaf138b50caa1aa4570541091cb7 (diff)
downloadruby-961101af6bfb7b9256a8183ce44804c476e5157a.tar.gz
ruby-961101af6bfb7b9256a8183ce44804c476e5157a.tar.xz
ruby-961101af6bfb7b9256a8183ce44804c476e5157a.zip
* ext/iconv/iconv.c (strip_glibc_option, map_charset): check if
encoding is a string. based on the patch by Hiroshi Moriyama at [ruby-dev:36811]. * test/iconv/test_basic.rb (test_invalid_arguments): added tests. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@19866 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/iconv')
-rw-r--r--ext/iconv/iconv.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/ext/iconv/iconv.c b/ext/iconv/iconv.c
index f80a553ed..6ff49e5b5 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);