From 99d96a89ce57edc4de2ff1acb1d4ed7737144140 Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 4 Aug 2010 07:09:47 +0000 Subject: * string.c (rb_str_resize): should copy the content properly. a patch from Jeremy Evans at [ruby-core:31615]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28851 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/-test-/bug-3652/bug.c | 16 ++++++++++++++++ ext/-test-/bug-3652/extconf.rb | 1 + 2 files changed, 17 insertions(+) create mode 100644 ext/-test-/bug-3652/bug.c create mode 100644 ext/-test-/bug-3652/extconf.rb (limited to 'ext/-test-') diff --git a/ext/-test-/bug-3652/bug.c b/ext/-test-/bug-3652/bug.c new file mode 100644 index 0000000000..290ac2ddee --- /dev/null +++ b/ext/-test-/bug-3652/bug.c @@ -0,0 +1,16 @@ +#include + +static VALUE +bug_str_resize(VALUE self, VALUE init, VALUE repl) +{ + long initlen = NUM2LONG(init); + VALUE s = rb_str_buf_new(initlen); + return rb_str_resize(s, strlcpy(RSTRING_PTR(s), StringValueCStr(repl), (size_t)initlen)); +} + +void +Init_bug(void) +{ + VALUE mBug = rb_define_module("Bug"); + rb_define_module_function(mBug, "str_resize", bug_str_resize, 2); +} diff --git a/ext/-test-/bug-3652/extconf.rb b/ext/-test-/bug-3652/extconf.rb new file mode 100644 index 0000000000..44f57b41c8 --- /dev/null +++ b/ext/-test-/bug-3652/extconf.rb @@ -0,0 +1 @@ +create_makefile("-test-/bug-3652/bug") -- cgit v1.2.3