summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-11-25 01:57:48 +0000
committershugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-11-25 01:57:48 +0000
commit94da8b17374a71b451e9b7f3b6e97ab058bdbc81 (patch)
tree474d3da0b385314074c2cccdadd108f7764c7c9c
parentff838167ba8ce85f9045a7fc484f6f6cb3666ff3 (diff)
* 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/trunk@52745 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog6
-rw-r--r--io.c4
-rw-r--r--test/ruby/test_argf.rb11
3 files changed, 20 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 99381a8881..25905864c6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Wed Nov 25 10:55:21 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]
+
Tue Nov 24 23:56:25 2015 Naohisa Goto <ngotogenome@gmail.com>
* configure.in: On Solaris, it is safe to define _LARGEFILE_SOURCE
diff --git a/io.c b/io.c
index 11b6499a41..9d75c230f4 100644
--- a/io.c
+++ b/io.c
@@ -11247,7 +11247,9 @@ argf_getpartial(int argc, VALUE *argv, VALUE argf, VALUE opts, 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 cb27b9c64e..e40b038967 100644
--- a/test/ruby/test_argf.rb
+++ b/test/ruby/test_argf.rb
@@ -510,6 +510,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 = ""