about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2018-07-15 00:58:37 +0000
committerEric Wong <e@80x24.org>2018-07-15 01:01:39 +0000
commitfd9847c808c421a201ae574d93f6d0ea36d9ec63 (patch)
tree9553008576ab6aae49a1478653e5f835085f0c7a
parent45e1931c71095e9cd18067e69ec93f503c700f86 (diff)
downloadmwrap-fd9847c808c421a201ae574d93f6d0ea36d9ec63.tar.gz
Users may screw up ordering of arguments :x
-rw-r--r--ext/mwrap/mwrap.c1
-rw-r--r--test/test_mwrap.rb4
2 files changed, 5 insertions, 0 deletions
diff --git a/ext/mwrap/mwrap.c b/ext/mwrap/mwrap.c
index 3f59f11..c160e33 100644
--- a/ext/mwrap/mwrap.c
+++ b/ext/mwrap/mwrap.c
@@ -346,6 +346,7 @@ static VALUE mwrap_dump(int argc, VALUE * argv, VALUE mod)
                 io = *((VALUE *)dlsym(RTLD_DEFAULT, "rb_stderr"));
 
         a.min = NIL_P(min) ? 0 : NUM2SIZET(min);
+        io = rb_io_get_io(io);
         io = rb_io_get_write_io(io);
         GetOpenFile(io, fptr);
         a.fp = rb_io_stdio_file(fptr);
diff --git a/test/test_mwrap.rb b/test/test_mwrap.rb
index 3de9c1b..d76e4da 100644
--- a/test/test_mwrap.rb
+++ b/test/test_mwrap.rb
@@ -155,4 +155,8 @@ class TestMwrap < Test::Unit::TestCase
     warn Benchmark::Tms::CAPTION
     warn r.read
   end if ENV['BENCHMARK']
+
+  def test_mwrap_dump_check
+    assert_raise(TypeError) { Mwrap.dump(:bogus) }
+  end
 end