1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

thread.c: check initialized

* ext/thread/thread.c (get_array): check instance variables are
  initialized properly.  [ruby-core:63826][Bug #10062]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47217 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2014-08-19 01:13:24 +00:00
parent 1d196e0d2b
commit a198bb3929
4 changed files with 37 additions and 4 deletions

View file

@ -1,3 +1,8 @@
Tue Aug 19 10:13:23 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/thread/thread.c (get_array): check instance variables are
initialized properly. [ruby-core:63826][Bug #10062]
Mon Aug 18 17:06:27 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
* sprintf.c (rb_str_format): support rational 'f' format.

View file

@ -11,14 +11,24 @@ enum {
SZQUEUE_MAX = 3
};
#define GET_CONDVAR_WAITERS(cv) RSTRUCT_GET((cv), CONDVAR_WAITERS)
#define GET_CONDVAR_WAITERS(cv) get_array((cv), CONDVAR_WAITERS)
#define GET_QUEUE_QUE(q) RSTRUCT_GET((q), QUEUE_QUE)
#define GET_QUEUE_WAITERS(q) RSTRUCT_GET((q), QUEUE_WAITERS)
#define GET_SZQUEUE_WAITERS(q) RSTRUCT_GET((q), SZQUEUE_WAITERS)
#define GET_QUEUE_QUE(q) get_array((q), QUEUE_QUE)
#define GET_QUEUE_WAITERS(q) get_array((q), QUEUE_WAITERS)
#define GET_SZQUEUE_WAITERS(q) get_array((q), SZQUEUE_WAITERS)
#define GET_SZQUEUE_MAX(q) RSTRUCT_GET((q), SZQUEUE_MAX)
#define GET_SZQUEUE_ULONGMAX(q) NUM2ULONG(GET_SZQUEUE_MAX(q))
static VALUE
get_array(VALUE obj, int idx)
{
VALUE ary = RSTRUCT_GET(obj, idx);
if (!RB_TYPE_P(ary, T_ARRAY)) {
rb_raise(rb_eTypeError, "%+"PRIsVALUE" not initialized", obj);
}
return ary;
}
static VALUE
ary_buf_new(void)
{

View file

@ -4,6 +4,12 @@ require 'tmpdir'
require_relative '../ruby/envutil'
class TestConditionVariable < Test::Unit::TestCase
def test_initialized
assert_raise(TypeError) {
ConditionVariable.allocate.wait(nil)
}
end
def test_condvar_signal_and_wait
mutex = Mutex.new
condvar = ConditionVariable.new

View file

@ -5,6 +5,18 @@ require 'timeout'
require_relative '../ruby/envutil'
class TestQueue < Test::Unit::TestCase
def test_queue_initialized
assert_raise(TypeError) {
Queue.allocate.push(nil)
}
end
def test_sized_queue_initialized
assert_raise(TypeError) {
SizedQueue.allocate.push(nil)
}
end
def test_queue
grind(5, 1000, 15, Queue)
end