diff options
author | Kenta Murata <[email protected]> | 2020-01-17 09:55:50 +0900 |
---|---|---|
committer | Kenta Murata <[email protected]> | 2020-01-17 10:06:58 +0900 |
commit | 07ce51c5aaf25a5a184a35074a40138256a0c099 (patch) | |
tree | a04d47225aad8c7b25af42e48b45acd1633d9762 /internal/rational.h | |
parent | fbc00c2d863f6cdeb65203e798b08157997cf786 (diff) |
internal/rational.h: insert assertions in RATIONAL_SET_{NUM,DEN}
Diffstat (limited to 'internal/rational.h')
-rw-r--r-- | internal/rational.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/internal/rational.h b/internal/rational.h index 028fc4c03e..d514050641 100644 --- a/internal/rational.h +++ b/internal/rational.h @@ -12,6 +12,8 @@ #include "ruby/config.h" /* for HAVE_LIBGMP */ #include "ruby/ruby.h" /* for struct RBasic */ #include "internal/gc.h" /* for RB_OBJ_WRITE */ +#include "internal/numeric.h" /* for INT_POSITIVE_P */ +#include "ruby_assert.h" /* for assert */ struct RRational { struct RBasic basic; @@ -51,12 +53,15 @@ RUBY_SYMBOL_EXPORT_END static inline void RATIONAL_SET_NUM(VALUE r, VALUE n) { + assert(RB_INTEGER_TYPE_P(n)); RB_OBJ_WRITE(r, &RRATIONAL(r)->num, n); } static inline void RATIONAL_SET_DEN(VALUE r, VALUE d) { + assert(RB_INTEGER_TYPE_P(d)); + assert(INT_POSITIVE_P(d)); RB_OBJ_WRITE(r, &RRATIONAL(r)->den, d); } |