aboutsummaryrefslogtreecommitdiffstats
path: root/string.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-09 02:29:24 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-09 02:29:24 +0000
commit54c146d2c3d8a9a5e3d4bbd8b5fd61e17ad45819 (patch)
treed2b105360fbe0b0ee6f508772d76510471e3f63e /string.c
parent221e6de720042585265cb38c05701663829ac40d (diff)
downloadruby-54c146d2c3d8a9a5e3d4bbd8b5fd61e17ad45819.tar.gz
* string.c (tr_trans): get rid of segfaults when has mulitbytes but
source sets have no mulitbytes. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14148 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r--string.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/string.c b/string.c
index 3811edc89c..8ed34edfd8 100644
--- a/string.c
+++ b/string.c
@@ -3466,7 +3466,7 @@ tr_trans(VALUE str, VALUE src, VALUE repl, int sflag)
v = trans[c] >= 0 ? trans[c] : Qnil;
}
else {
- v = rb_hash_aref(hash, INT2NUM(c));
+ v = hash ? rb_hash_aref(hash, INT2NUM(c)) : Qnil;
}
if (!NIL_P(v)) {
if (!cflag) {
@@ -3531,7 +3531,7 @@ tr_trans(VALUE str, VALUE src, VALUE repl, int sflag)
v = trans[c] >= 0 ? trans[c] : Qnil;
}
else {
- v = rb_hash_aref(hash, INT2NUM(c));
+ v = hash ? rb_hash_aref(hash, INT2NUM(c)) : Qnil;
}
if (!NIL_P(v)) {
if (!cflag) {