diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2017-12-12 10:25:02 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2017-12-12 17:45:15 +0900 |
| commit | d4ff92bcf65ce140495014f40d22b93a1b1fb957 (patch) | |
| tree | 9075f4bd70c7e227195d56220a3d046358a292dd /mrbgems/mruby-pack | |
| parent | 3d98fa2e46d6263e0644f4d57c69e437c72ac57a (diff) | |
| download | mruby-d4ff92bcf65ce140495014f40d22b93a1b1fb957.tar.gz mruby-d4ff92bcf65ce140495014f40d22b93a1b1fb957.zip | |
Do not use `FIXABLE` when `mrb_int` is big enough.
Diffstat (limited to 'mrbgems/mruby-pack')
| -rw-r--r-- | mrbgems/mruby-pack/src/pack.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/mrbgems/mruby-pack/src/pack.c b/mrbgems/mruby-pack/src/pack.c index 01dc4b16d..489ad3718 100644 --- a/mrbgems/mruby-pack/src/pack.c +++ b/mrbgems/mruby-pack/src/pack.c @@ -193,7 +193,9 @@ pack_l(mrb_state *mrb, mrb_value o, mrb_value str, mrb_int sidx, unsigned int fl static int unpack_l(mrb_state *mrb, const unsigned char *src, int srclen, mrb_value ary, unsigned int flags) { +#ifndef MRB_INT64 char msg[60]; +#endif uint32_t ul; mrb_int n; @@ -210,16 +212,20 @@ unpack_l(mrb_state *mrb, const unsigned char *src, int srclen, mrb_value ary, un } if (flags & PACK_FLAG_SIGNED) { int32_t sl = ul; +#ifndef MRB_INT64 if (!FIXABLE(sl)) { snprintf(msg, sizeof(msg), "cannot unpack to Fixnum: %ld", (long)sl); mrb_raise(mrb, E_RANGE_ERROR, msg); } +#endif n = sl; } else { +#ifndef MRB_INT64 if (!POSFIXABLE(ul)) { snprintf(msg, sizeof(msg), "cannot unpack to Fixnum: %lu", (unsigned long)ul); mrb_raise(mrb, E_RANGE_ERROR, msg); } +#endif n = ul; } mrb_ary_push(mrb, ary, mrb_fixnum_value(n)); |
