ruby-changes:62012
From: =E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3 <ko1@a...>
Date: Mon, 29 Jun 2020 11:07:28 +0900 (JST)
Subject: [ruby-changes:62012] 41703fcfab (master): r_object0: do not goto into a branch
https://git.ruby-lang.org/ruby.git/commit/?id=41703fcfab From 41703fcfabee00320f67875d743f4bc002eb65c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?= <shyouhei@r...> Date: Mon, 15 Jun 2020 16:09:33 +0900 Subject: r_object0: do not goto into a branch I'm not necessarily against every goto in general, but jumping into a branch is definitely a bad idea. Better refactor. diff --git a/marshal.c b/marshal.c index 88ea291..480ae59 100644 --- a/marshal.c +++ b/marshal.c @@ -1739,8 +1739,7 @@ r_object0(struct load_arg *arg, int *ivp, VALUE extmod) https://github.com/ruby/ruby/blob/trunk/marshal.c#L1739 } v = r_object0(arg, 0, extmod); if (rb_special_const_p(v) || RB_TYPE_P(v, T_OBJECT) || RB_TYPE_P(v, T_CLASS)) { - format_error: - rb_raise(rb_eArgError, "dump format error (user class)"); + goto format_error; } if (RB_TYPE_P(v, T_MODULE) || !RTEST(rb_class_inherited_p(c, RBASIC(v)->klass))) { VALUE tmp = rb_obj_alloc(c); @@ -1751,6 +1750,9 @@ r_object0(struct load_arg *arg, int *ivp, VALUE extmod) https://github.com/ruby/ruby/blob/trunk/marshal.c#L1750 } break; + format_error: + rb_raise(rb_eArgError, "dump format error (user class)"); + case TYPE_NIL: v = Qnil; v = r_leave(v, arg); -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/