summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-05-04 15:18:42 +0000
committershyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-05-04 15:18:42 +0000
commit1096be5ac6540c204047c7c9e6d58bfcef90e167 (patch)
tree167ec359660da444943d35a970a4106e67379fce
parent7ba44caaf3ef733817d236f8f019041838b65293 (diff)
passing rb_thread_sleep to rb_protect is IMHO dangerous
rb_thread_sleep's argument is int, while rb_protect expects the function to take VALUE. Depending on ABI this could be a problem. We should wrap rb_thread_sleep here. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63339 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--process.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/process.c b/process.c
index b6a0245163..a1154bda8e 100644
--- a/process.c
+++ b/process.c
@@ -3270,6 +3270,13 @@ pipe_nocrash(int filedes[2], VALUE fds)
#define O_BINARY 0
#endif
+static VALUE
+rb_thread_sleep_that_takes_VALUE_as_sole_argument(VALUE n)
+{
+ rb_thread_sleep(NUM2INT(n));
+ return Qundef;
+}
+
static int
handle_fork_error(int err, int *status, int *ep, volatile int *try_gc_p)
{
@@ -3291,7 +3298,7 @@ handle_fork_error(int err, int *status, int *ep, volatile int *try_gc_p)
return 0;
}
else {
- rb_protect((VALUE (*)())rb_thread_sleep, 1, &state);
+ rb_protect(rb_thread_sleep_that_takes_VALUE_as_sole_argument, 1, &state);
if (status) *status = state;
if (!state) return 0;
}