summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-02-11 10:45:34 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-02-11 10:45:34 (GMT)
commit96c078c34029bbc525085c4072b7e1ebcc9ec5a3 (patch)
tree12d7aa3e5192ad8c8416ce85889aaaac5e71561e
parent18364f541b83eddd3b35fa42077f58a8782369f0 (diff)
* eval.c (ruby_cleanup): use rb_ary_free to free internal object.
* gc.h (RUBY_FREE_UNLESS_NULL): get rid of double free. [ruby-core:35192] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30840 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog7
-rw-r--r--eval.c2
-rw-r--r--gc.h2
-rw-r--r--test/ruby/test_thread.rb11
-rw-r--r--vm.c2
5 files changed, 20 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index ae67b3e..f9e9c09 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Fri Feb 11 19:45:26 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * eval.c (ruby_cleanup): use rb_ary_free to free internal object.
+
+ * gc.h (RUBY_FREE_UNLESS_NULL): get rid of double free.
+ [ruby-core:35192]
+
Fri Feb 11 16:57:03 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
* test/ruby/test_transcode.rb (test_from_cp50221): fix wrong
diff --git a/eval.c b/eval.c
index 5fe00e1..18ea100 100644
--- a/eval.c
+++ b/eval.c
@@ -170,7 +170,7 @@ ruby_cleanup(volatile int ex)
for (i=RARRAY_LEN(ary) - 1; i>=0; i--) {
((void(*)(rb_vm_t*))RARRAY_PTR(ary)[i])(vm);
}
- rb_ary_clear(ary);
+ rb_ary_free(ary);
#if EXIT_SUCCESS != 0 || EXIT_FAILURE != 1
switch (ex) {
diff --git a/gc.h b/gc.h
index e782ad4..df2cf7d 100644
--- a/gc.h
+++ b/gc.h
@@ -58,7 +58,7 @@ rb_gc_debug_body(const char *mode, const char *msg, int st, void *ptr)
#endif
#define RUBY_MARK_UNLESS_NULL(ptr) if(RTEST(ptr)){rb_gc_mark(ptr);}
-#define RUBY_FREE_UNLESS_NULL(ptr) if(ptr){ruby_xfree(ptr);}
+#define RUBY_FREE_UNLESS_NULL(ptr) if(ptr){ruby_xfree(ptr);(ptr)=NULL;}
#if STACK_GROW_DIRECTION > 0
# define STACK_UPPER(x, a, b) (a)
diff --git a/test/ruby/test_thread.rb b/test/ruby/test_thread.rb
index 4e53b7f..4089eb6 100644
--- a/test/ruby/test_thread.rb
+++ b/test/ruby/test_thread.rb
@@ -384,7 +384,7 @@ class TestThread < Test::Unit::TestCase
end
INPUT
- assert_in_out_err(%w(--disable-gems -d), <<-INPUT, %w(false 2), /.+/)
+ assert_in_out_err(%w(--disable-gems -d), <<-INPUT, %w(false 2), %r".+")
p Thread.abort_on_exception
begin
Thread.new { raise }
@@ -577,6 +577,15 @@ class TestThread < Test::Unit::TestCase
assert_nothing_raised {arr.hash}
assert(obj[:visited])
end
+
+ def test_thread_instance_variable
+ bug4389 = '[ruby-core:35192]'
+ assert_in_out_err([], <<-INPUT, %w(), [], bug4389)
+ class << Thread.current
+ @data = :data
+ end
+ INPUT
+ end
end
class TestThreadGroup < Test::Unit::TestCase
diff --git a/vm.c b/vm.c
index d0c2592..8017c42 100644
--- a/vm.c
+++ b/vm.c
@@ -230,7 +230,7 @@ env_free(void * const ptr)
{
RUBY_FREE_ENTER("env");
if (ptr) {
- const rb_env_t * const env = ptr;
+ rb_env_t *const env = ptr;
RUBY_FREE_UNLESS_NULL(env->env);
ruby_xfree(ptr);
}