diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2019-07-11 19:20:53 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2019-07-11 20:04:29 +0900 |
commit | 3e7d002118a92fad5934e11c75be6768a1476c1b (patch) | |
tree | e9f437327b5c743622a97c092ddadc2d99cb0bc5 /ext/bigdecimal/bigdecimal.c | |
parent | cd069df36596d9bf7a6db8aaa0dcefdafb233a91 (diff) |
Check exception flag as a bool [Bug #15987]
Diffstat (limited to 'ext/bigdecimal/bigdecimal.c')
-rw-r--r-- | ext/bigdecimal/bigdecimal.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c index da1b24a631..430707a4d6 100644 --- a/ext/bigdecimal/bigdecimal.c +++ b/ext/bigdecimal/bigdecimal.c @@ -2560,6 +2560,10 @@ BigDecimal_clone(VALUE self) return self; } +#ifdef HAVE_RB_OPTS_EXCEPTION_P +int rb_opts_exception_p(VALUE opts, int default_value); +#define opts_exception_p(opts) rb_opts_exception_p((opts), 1) +#else static int opts_exception_p(VALUE opts) { @@ -2569,8 +2573,16 @@ opts_exception_p(VALUE opts) kwds[0] = rb_intern_const("exception"); } rb_get_kwargs(opts, kwds, 0, 1, &exception); + switch (exception) { + case Qtrue: case Qfalse: + break; + default: + rb_raise(rb_eArgError, "true or false is expected as exception: %+"PRIsVALUE, + flagname, obj); + } return exception != Qfalse; } +#endif static Real * BigDecimal_new(int argc, VALUE *argv) |