summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--node.c24
-rw-r--r--string.c16
-rw-r--r--test/ruby/test_process.rb10
4 files changed, 39 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index 2793621ad9..5f26aae48c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Thu Aug 6 02:25:31 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * node.c (rb_alloc_tmp_buffer): use NODE_ALLOCA to mark locations
+ like as builtin alloca. [ruby-core:70251] [Bug #11418]
+
Wed Aug 5 14:37:55 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
* transcode.c (rb_econv_open0): rb_econv_t::source_encoding_name
diff --git a/node.c b/node.c
index 79f65ec684..7551a811c8 100644
--- a/node.c
+++ b/node.c
@@ -1075,3 +1075,27 @@ rb_gc_mark_node(NODE *obj)
}
return 0;
}
+
+void *
+rb_alloc_tmp_buffer(volatile VALUE *store, long len)
+{
+ NODE *s = rb_node_newnode(NODE_ALLOCA, 0, 0, 0);
+ void *ptr = xmalloc(len);
+ s->u1.node = ptr;
+ s->u3.cnt = len / sizeof(VALUE);
+ *store = (VALUE)s;
+ return ptr;
+}
+
+void
+rb_free_tmp_buffer(volatile VALUE *store)
+{
+ VALUE s = *store;
+ *store = 0;
+ if (s) {
+ void *ptr = RNODE(s)->u1.node;
+ RNODE(s)->u1.node = 0;
+ RNODE(s)->u3.cnt = 0;
+ xfree(ptr);
+ }
+}
diff --git a/string.c b/string.c
index 2c4fc7405b..99799978cb 100644
--- a/string.c
+++ b/string.c
@@ -1116,22 +1116,6 @@ rb_str_tmp_new(long len)
return str_new(0, 0, len);
}
-void *
-rb_alloc_tmp_buffer(volatile VALUE *store, long len)
-{
- VALUE s = rb_str_tmp_new(len);
- *store = s;
- return RSTRING_PTR(s);
-}
-
-void
-rb_free_tmp_buffer(volatile VALUE *store)
-{
- VALUE s = *store;
- *store = 0;
- if (s) rb_str_clear(s);
-}
-
void
rb_str_free(VALUE str)
{
diff --git a/test/ruby/test_process.rb b/test/ruby/test_process.rb
index 68dab2b8ad..2a5a586353 100644
--- a/test/ruby/test_process.rb
+++ b/test/ruby/test_process.rb
@@ -2172,4 +2172,14 @@ EOS
w.close if w
r.close if r
end if defined?(fork)
+
+ def test_many_args
+ bug11418 = '[ruby-core:70251] [Bug #11418]'
+ assert_in_out_err([], <<-"end;", ["x"]*256, [], bug11418)
+ bin = "#{EnvUtil.rubybin}"
+ args = Array.new(256) {"x"}
+ GC.stress = true
+ system(bin, "--disable=gems", "-w", "-e", "puts ARGV", *args)
+ end;
+ end
end