mtasaka / rpms / ruby

Forked from rpms/ruby 3 years ago
Clone
3210f66
From 85310ad82ede533681c4f8a423cc8f140e6adf76 Mon Sep 17 00:00:00 2001
3210f66
From: Nobuyoshi Nakada <nobu@ruby-lang.org>
3210f66
Date: Tue, 9 Feb 2021 10:08:30 +0900
3210f66
Subject: [PATCH 1/2] Also `eclass` loop can raise in `rb_obj_is_kind_of`
3210f66
3210f66
---
3210f66
 eval.c | 2 +-
3210f66
 1 file changed, 1 insertion(+), 1 deletion(-)
3210f66
3210f66
diff --git a/eval.c b/eval.c
3210f66
index 56d7c2b81c93..2c9e375e2545 100644
3210f66
--- a/eval.c
3210f66
+++ b/eval.c
3210f66
@@ -1034,6 +1034,7 @@ rb_vrescue2(VALUE (* b_proc) (VALUE), VALUE data1,
3210f66
 	    int handle = FALSE;
3210f66
 	    VALUE eclass;
3210f66
 
3210f66
+	    result = Qnil;
3210f66
 	    while ((eclass = va_arg(args, VALUE)) != 0) {
3210f66
 		if (rb_obj_is_kind_of(ec->errinfo, eclass)) {
3210f66
 		    handle = TRUE;
3210f66
@@ -1042,7 +1043,6 @@ rb_vrescue2(VALUE (* b_proc) (VALUE), VALUE data1,
3210f66
 	    }
3210f66
 
3210f66
 	    if (handle) {
3210f66
-		result = Qnil;
3210f66
 		state = 0;
3210f66
 		if (r_proc) {
3210f66
 		    result = (*r_proc) (data2, ec->errinfo);
3210f66
3210f66
From 601d38efa21dbed0084629d909752e52e3d6092d Mon Sep 17 00:00:00 2001
3210f66
From: Nobuyoshi Nakada <nobu@ruby-lang.org>
3210f66
Date: Tue, 9 Feb 2021 00:42:12 +0900
3210f66
Subject: [PATCH 2/2] Copy va_list of exception classes
3210f66
3210f66
The list is reused when an exception raised again after retrying
3210f66
in the rescue procedure.
3210f66
---
3210f66
 eval.c | 6 +++++-
3210f66
 1 file changed, 5 insertions(+), 1 deletion(-)
3210f66
3210f66
diff --git a/eval.c b/eval.c
3210f66
index 2c9e375e2545..55d66b550854 100644
3210f66
--- a/eval.c
3210f66
+++ b/eval.c
3210f66
@@ -1033,14 +1033,18 @@ rb_vrescue2(VALUE (* b_proc) (VALUE), VALUE data1,
3210f66
 	if (state == TAG_RAISE) {
3210f66
 	    int handle = FALSE;
3210f66
 	    VALUE eclass;
3210f66
+	    va_list ap;
3210f66
 
3210f66
 	    result = Qnil;
3210f66
-	    while ((eclass = va_arg(args, VALUE)) != 0) {
3210f66
+	    /* reuses args when raised again after retrying in r_proc */
3210f66
+	    va_copy(ap, args);
3210f66
+	    while ((eclass = va_arg(ap, VALUE)) != 0) {
3210f66
 		if (rb_obj_is_kind_of(ec->errinfo, eclass)) {
3210f66
 		    handle = TRUE;
3210f66
 		    break;
3210f66
 		}
3210f66
 	    }
3210f66
+	    va_end(ap);
3210f66
 
3210f66
 	    if (handle) {
3210f66
 		state = 0;