From 513a7a751d5b04608e57f9d4dcd83cda69dc3e94 Mon Sep 17 00:00:00 2001 From: akr Date: Sat, 10 Nov 2007 14:53:26 +0000 Subject: * 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. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@13872 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- string.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'string.c') diff --git a/string.c b/string.c index 07ccf897c..4ff50a776 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]); -- cgit