summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-sprintf
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2017-03-11 15:22:42 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2017-03-11 15:22:42 +0900
commitf30ec2dfb0217fd1426dbdfa1db22da51bbe73b5 (patch)
treecfc6e27f380967f11a552cd92720bef7e643d7e3 /mrbgems/mruby-sprintf
parente3922318bd2679de7930ba7c520d58961340e006 (diff)
downloadmruby-f30ec2dfb0217fd1426dbdfa1db22da51bbe73b5.tar.gz
mruby-f30ec2dfb0217fd1426dbdfa1db22da51bbe73b5.zip
fixup! Check return value from snprintf(); ref #3498
Diffstat (limited to 'mrbgems/mruby-sprintf')
-rw-r--r--mrbgems/mruby-sprintf/src/sprintf.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/mrbgems/mruby-sprintf/src/sprintf.c b/mrbgems/mruby-sprintf/src/sprintf.c
index a3e20d83a..fcda7733d 100644
--- a/mrbgems/mruby-sprintf/src/sprintf.c
+++ b/mrbgems/mruby-sprintf/src/sprintf.c
@@ -1049,7 +1049,10 @@ retry:
need = width;
CHECK(need + 1);
- snprintf(&buf[blen], need + 1, "%*s", need, "");
+ n = snprintf(&buf[blen], need + 1, "%*s", need, "");
+ if (n < 0) {
+ mrb_raise(mrb, E_RUNTIME_ERROR, "formatting error");
+ }
if (flags & FMINUS) {
if (!isnan(fval) && fval < 0.0)
buf[blen++] = '-';