summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-01-16 18:40:22 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-01-16 18:40:22 +0000
commit2e4b5a32f27d46494198c8e1f62da2c5abb9c883 (patch)
treeab2d312d36e3a6ad12e2cc4512466b1600ae6f57 /test
parentf9664eb3c797e4c6ec4061f74996dfac737d407f (diff)
merge revision(s) 57108: [Backport #13121]
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/branches/ruby_2_3@57340 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_sprintf.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/test/ruby/test_sprintf.rb b/test/ruby/test_sprintf.rb
index 8aa0cbfea5..f94d38d510 100644
--- a/test/ruby/test_sprintf.rb
+++ b/test/ruby/test_sprintf.rb
@@ -433,4 +433,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