aboutsummaryrefslogtreecommitdiffstats
path: root/string.c
diff options
context:
space:
mode:
Diffstat (limited to 'string.c')
-rw-r--r--string.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/string.c b/string.c
index 32dd4d9cf0..ee8641e9b2 100644
--- a/string.c
+++ b/string.c
@@ -5357,11 +5357,11 @@ rb_str_chomp_bang(int argc, VALUE *argv, VALUE str)
if (rslen == 1 && newline == '\n')
goto smart_chomp;
+ enc = rb_enc_check(str, rs);
if (is_broken_string(rs)) {
return Qnil;
}
pp = e - rslen;
- enc = rb_enc_check(str, rs);
if (p[len-1] == newline &&
(rslen <= 1 ||
memcmp(RSTRING_PTR(rs), pp, rslen) == 0)) {