unsigned long may be smaller than mrb_int; use uint64_t instead; fix #2935

parent 3a462fe4
...@@ -73,7 +73,7 @@ mrb_fix2binstr(mrb_state *mrb, mrb_value x, int base) ...@@ -73,7 +73,7 @@ mrb_fix2binstr(mrb_state *mrb, mrb_value x, int base)
{ {
char buf[64], *b = buf + sizeof buf; char buf[64], *b = buf + sizeof buf;
mrb_int num = mrb_fixnum(x); mrb_int num = mrb_fixnum(x);
unsigned long val = (unsigned long)num; uint64_t val = (uint64_t)num;
char d; char d;
if (base != 2) { if (base != 2) {
......
...@@ -1863,7 +1863,7 @@ mrb_cstr_to_inum(mrb_state *mrb, const char *str, int base, int badcheck) ...@@ -1863,7 +1863,7 @@ mrb_cstr_to_inum(mrb_state *mrb, const char *str, int base, int badcheck)
const char *p; const char *p;
char sign = 1; char sign = 1;
int c, uscore; int c, uscore;
unsigned long n = 0; uint64_t n = 0;
mrb_int val; mrb_int val;
#define conv_digit(c) \ #define conv_digit(c) \
...@@ -1983,9 +1983,9 @@ mrb_cstr_to_inum(mrb_state *mrb, const char *str, int base, int badcheck) ...@@ -1983,9 +1983,9 @@ mrb_cstr_to_inum(mrb_state *mrb, const char *str, int base, int badcheck)
} }
n *= base; n *= base;
n += c; n += c;
} if (n > MRB_INT_MAX) {
if (n > MRB_INT_MAX) { mrb_raisef(mrb, E_ARGUMENT_ERROR, "string (%S) too big for integer", mrb_str_new_cstr(mrb, str));
mrb_raisef(mrb, E_ARGUMENT_ERROR, "string (%S) too big for integer", mrb_str_new_cstr(mrb, str)); }
} }
val = n; val = n;
if (badcheck) { if (badcheck) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment