Project

General

Profile

Actions

Bug #11387

closed

String#force_encoding と String#reverse の後にSEGV

Added by tatzyr (Tatsuya Otsuka) over 9 years ago. Updated over 9 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.3.0dev (2015-07-22 trunk 51342) [x86_64-darwin14]
[ruby-dev:49189]

Description

以下のコードでSEGVします。

broken_str = "abcd\xf0"
broken_str.force_encoding("utf-8").reverse
p broken_str.reverse

また、以下のコードでは String#splitArgumentError (invalid byte sequence in UTF-8)
発生することが期待されますが、実際は例外が発生しません。

broken_str = "abcd\xf0"
broken_str.force_encoding("utf-8").reverse
"".split(broken_str)

Files

stdout-and-stderr.txt (3.97 KB) stdout-and-stderr.txt tatzyr (Tatsuya Otsuka), 07/22/2015 01:28 PM

Updated by nobu (Nobuyoshi Nakada) over 9 years ago

  • Description updated (diff)
  • Backport changed from 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN to 2.0.0: REQUIRED, 2.1: REQUIRED, 2.2: REQUIRED
Actions #3

Updated by nobu (Nobuyoshi Nakada) over 9 years ago

  • Status changed from Open to Closed

Applied in changeset r51344.


string.c: fix coderange of reverse

  • string.c (rb_str_reverse): reversed string is not a substring,
    and should not set coderange of the original string.
    [ruby-dev:49189] [Bug #11387]

Updated by nagachika (Tomoyuki Chikanaga) over 9 years ago

  • Backport changed from 2.0.0: REQUIRED, 2.1: REQUIRED, 2.2: REQUIRED to 2.0.0: REQUIRED, 2.1: REQUIRED, 2.2: DONE

Backported into ruby_2_2 branch at r51520.

Actions #5

Updated by usa (Usaku NAKAMURA) over 9 years ago

  • Backport changed from 2.0.0: REQUIRED, 2.1: REQUIRED, 2.2: DONE to 2.0.0: REQUIRED, 2.1: DONE, 2.2: DONE

ruby_2_1 r51600 merged revision(s) 51344.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0