aboutsummaryrefslogtreecommitdiffstats
path: root/string.c
diff options
context:
space:
mode:
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) {