diff --git a/ChangeLog b/ChangeLog index 1543907c3f..563199b1ab 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Sat Nov 10 23:50:31 2007 Tanaka Akira + + * string.c (tr_trans): cast to unsigned char after dereference + a pointer to a char to avoid SEGV with "\377".tr("a", "b"). + on FreeBSD/amd64. + Sat Nov 10 23:08:53 2007 Tanaka Akira * configure.in, common.mk, Makefile.in: don't generate diff --git a/string.c b/string.c index 07ccf897c7..4ff50a776d 100644 --- a/string.c +++ b/string.c @@ -3475,7 +3475,7 @@ tr_trans(VALUE str, VALUE src, VALUE repl, int sflag) } else if (rb_enc_mbmaxlen(enc) == 1) { while (s < send) { - c = *s; + c = (unsigned char)*s; if (trans[c] >= 0) { if (!cflag) { c = FIX2INT(trans[c]);