summaryrefslogtreecommitdiffhomepage
path: root/src/error.c
diff options
context:
space:
mode:
authordearblue <[email protected]>2019-09-08 20:31:35 +0900
committerdearblue <[email protected]>2019-09-08 20:31:35 +0900
commit311d867deb27591210321b9407a7095799f552f8 (patch)
treed99fd9c973bf034409647599ebce9a30976293ee /src/error.c
parentbb7eccc9c4e38bf247eb90e55f4f88e2a4af1762 (diff)
downloadmruby-311d867deb27591210321b9407a7095799f552f8.tar.gz
mruby-311d867deb27591210321b9407a7095799f552f8.zip
Fix `mrb_vformat()` crashes with `MRB_INT16`
If `MRB_INT16` is specified, the variable length argument `mrb_int` is converted to `int`.
Diffstat (limited to 'src/error.c')
-rw-r--r--src/error.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/error.c b/src/error.c
index bb8a0ba98..2bb505d85 100644
--- a/src/error.c
+++ b/src/error.c
@@ -326,7 +326,11 @@ mrb_vformat(mrb_state *mrb, const char *format, va_list ap)
len = 1;
goto L_cat;
case 'd': case 'i':
+#if MRB_INT_MAX < INT_MAX
+ i = (mrb_int)va_arg(ap, int);
+#else
i = *p == 'd' ? (mrb_int)va_arg(ap, int) : va_arg(ap, mrb_int);
+#endif
obj = mrb_fixnum_value(i);
goto L_cat_obj;
#ifndef MRB_WITHOUT_FLOAT