From 75755ef159caafd4d2623b81928b4f7c0791f209 Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 16 Dec 2016 01:12:09 +0000 Subject: fix chomping newline only line * string.c (chomp_newline): fix chomping newline only line. rb_enc_prev_char return NULL if no previous character and must not call rb_enc_ascget on it. a patch by Ary Borenszweig at [ruby-core:78666]. [Bug #13037] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57088 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 8515773a84..fd17355346 100644 --- a/string.c +++ b/string.c @@ -7409,7 +7409,7 @@ chomp_newline(const char *p, const char *e, rb_encoding *enc) if (rb_enc_is_newline(prev, e, enc)) { e = prev; prev = rb_enc_prev_char(p, e, e, enc); - if (rb_enc_ascget(prev, e, NULL, enc) == '\r') + if (prev && rb_enc_ascget(prev, e, NULL, enc) == '\r') e = prev; } return e; -- cgit v1.2.3