summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2019-09-08 22:46:25 +0900
committerGitHub <[email protected]>2019-09-08 22:46:25 +0900
commit715afd6fdb7c5c080fa8e3c2060394cf84f530ac (patch)
tree07a8dc7c0b8ddb102e0c476e75f5aa952c5b4ad6 /src
parent801343b56bf401e067880f2fd86e0aa3646c3c3f (diff)
parent311d867deb27591210321b9407a7095799f552f8 (diff)
downloadmruby-715afd6fdb7c5c080fa8e3c2060394cf84f530ac.tar.gz
mruby-715afd6fdb7c5c080fa8e3c2060394cf84f530ac.zip
Merge pull request #4695 from dearblue/promote-to-int
Fix `mrb_vformat()` crashes with `MRB_INT16`
Diffstat (limited to 'src')
-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