From 0854193a684acc2b3a13ab28091a4397000c8822 Mon Sep 17 00:00:00 2001 From: nobu Date: Sat, 17 Dec 2016 18:04:30 +0000 Subject: sprintf.c: fix width underflow * sprintf.c (rb_str_format): fix memory corruption by width underflow. https://github.com/mruby/mruby/issues/3347 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57108 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_sprintf.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'test/ruby/test_sprintf.rb') diff --git a/test/ruby/test_sprintf.rb b/test/ruby/test_sprintf.rb index df9b19b064..595bf6d782 100644 --- a/test/ruby/test_sprintf.rb +++ b/test/ruby/test_sprintf.rb @@ -446,4 +446,9 @@ class TestSprintf < Test::Unit::TestCase h = { key: nil, key2: "key2_val" } assert_equal("key is , key2 is key2_val", "key is %{key}, key2 is %{key2}" % h) end + + def test_width_underflow + bug = 'https://github.com/mruby/mruby/issues/3347' + assert_equal("!", sprintf("%*c", 0, ?!.ord), bug) + end end -- cgit v1.2.3