summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-11-30 12:19:43 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-11-30 12:19:43 +0000
commit6602bc193b378f832e52f446df8804efafd5dfb8 (patch)
tree344bb18580b46ce9fdf18ce203aca0a44c96e98f
parent041afd1cfb337d1d056defa118281728185beb97 (diff)
merge revision(s) 52745: [Backport #11738]
* io.c (argf_getpartial): should not resize str if the second argument is not given. [ruby-core:71668] [Bug #11738] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@52800 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog6
-rw-r--r--io.c4
-rw-r--r--test/ruby/test_argf.rb11
-rw-r--r--version.h2
4 files changed, 21 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 7a3fe40bdf..eb9e72240e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Mon Nov 30 21:18:24 2015 Shugo Maeda <shugo@ruby-lang.org>
+
+ * io.c (argf_getpartial): should not resize str if the second
+ argument is not given.
+ [ruby-core:71668] [Bug #11738]
+
Mon Nov 30 21:17:08 2015 SHIBATA Hiroshi <hsbt@ruby-lang.org>
* lib/net/http.rb: set hostname before call ossl_ssl_set_session.
diff --git a/io.c b/io.c
index b86ebe8e7f..249218d2c5 100644
--- a/io.c
+++ b/io.c
@@ -10967,7 +10967,9 @@ argf_getpartial(int argc, VALUE *argv, VALUE argf, int nonblock)
}
if (!next_argv()) {
- rb_str_resize(str, 0);
+ if (!NIL_P(str)) {
+ rb_str_resize(str, 0);
+ }
rb_eof_error();
}
if (ARGF_GENERIC_INPUT_P()) {
diff --git a/test/ruby/test_argf.rb b/test/ruby/test_argf.rb
index fb869561a1..104a681ee0 100644
--- a/test/ruby/test_argf.rb
+++ b/test/ruby/test_argf.rb
@@ -504,6 +504,17 @@ class TestArgf < Test::Unit::TestCase
end
end
+ def test_readpartial_eof_twice
+ ruby('-W1', '-e', <<-SRC, @t1.path) do |f|
+ $stderr = $stdout
+ print ARGF.readpartial(256)
+ ARGF.readpartial(256) rescue p($!.class)
+ ARGF.readpartial(256) rescue p($!.class)
+ SRC
+ assert_equal("1\n2\nEOFError\nEOFError\n", f.read)
+ end
+ end
+
def test_getc
ruby('-e', <<-SRC, @t1.path, @t2.path, @t3.path) do |f|
s = ""
diff --git a/version.h b/version.h
index 1b321b4d1c..6a26e35dd8 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
#define RUBY_VERSION "2.1.8"
#define RUBY_RELEASE_DATE "2015-11-30"
-#define RUBY_PATCHLEVEL 425
+#define RUBY_PATCHLEVEL 426
#define RUBY_RELEASE_YEAR 2015
#define RUBY_RELEASE_MONTH 11