[前][次][番号順一覧][スレッド一覧]

ruby-changes:60553

From: Benoit <ko1@a...>
Date: Sat, 28 Mar 2020 21:04:53 +0900 (JST)
Subject: [ruby-changes:60553] 5fa12dafa8 (master): The last argument of rb_rescue2() should always be (VALUE)0

https://git.ruby-lang.org/ruby.git/commit/?id=5fa12dafa8

From 5fa12dafa8cb8f7158452356611967880745bba5 Mon Sep 17 00:00:00 2001
From: Benoit Daloze <eregontp@g...>
Date: Sat, 28 Mar 2020 13:03:17 +0100
Subject: The last argument of rb_rescue2() should always be (VALUE)0

* Otherwise it might segfault, since C has no idea of the type of varargs,
  and the C code must assume all varargs are VALUE.

diff --git a/eval.c b/eval.c
index a68c26a..b472fec 100644
--- a/eval.c
+++ b/eval.c
@@ -974,7 +974,7 @@ rb_rescue2(VALUE (* b_proc) (VALUE), VALUE data1, https://github.com/ruby/ruby/blob/trunk/eval.c#L974
 
 /*!
  * \copydoc rb_rescue2
- * \param[in] args exception classes, terminated by 0.
+ * \param[in] args exception classes, terminated by (VALUE)0.
  */
 VALUE
 rb_vrescue2(VALUE (* b_proc) (VALUE), VALUE data1,
diff --git a/ext/-test-/cxxanyargs/cxxanyargs.cpp b/ext/-test-/cxxanyargs/cxxanyargs.cpp
index 3079069..cafd7f5 100644
--- a/ext/-test-/cxxanyargs/cxxanyargs.cpp
+++ b/ext/-test-/cxxanyargs/cxxanyargs.cpp
@@ -181,13 +181,13 @@ namespace test_rb_rescue2 { https://github.com/ruby/ruby/blob/trunk/ext/-test-/cxxanyargs/cxxanyargs.cpp#L181
     test(VALUE self)
     {
 #ifdef HAVE_NULLPTR
-        rb_rescue2(RUBY_METHOD_FUNC(begin), self, nullptr, self, rb_eStandardError, rb_eFatal, 0);
-        rb_rescue2(begin, self, nullptr, self, rb_eStandardError, rb_eFatal, 0);
+        rb_rescue2(RUBY_METHOD_FUNC(begin), self, nullptr, self, rb_eStandardError, rb_eFatal, (VALUE)0);
+        rb_rescue2(begin, self, nullptr, self, rb_eStandardError, rb_eFatal, (VALUE)0);
 #endif
 
         rb_rescue2(RUBY_METHOD_FUNC(begin), self, RUBY_METHOD_FUNC(rescue), self,
-                   rb_eStandardError, rb_eFatal, 0); // old
-        return rb_rescue2(begin, self, rescue, self, rb_eStandardError, rb_eFatal, 0); // new
+                   rb_eStandardError, rb_eFatal, (VALUE)0); // old
+        return rb_rescue2(begin, self, rescue, self, rb_eStandardError, rb_eFatal, (VALUE)0); // new
     }
 }
 
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]