aboutsummaryrefslogtreecommitdiffstats
path: root/vsnprintf.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-05-25 02:56:36 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-05-25 02:56:36 +0000
commitbae87a479016504577b7def06f38615837f12b50 (patch)
tree20eed2f9caacc78727f7ef824495b8c42edb59d2 /vsnprintf.c
parent7833e69c2ea4c843f6930b4a80795025f36ab155 (diff)
downloadruby-bae87a479016504577b7def06f38615837f12b50.tar.gz
vsnprintf.c: fix string precision
* vsnprintf.c (BSD_vfprintf): fix string width when precision is given. as the result of `memchr` is NULL or its offset from the start cannot exceed the size, the comparison was always false. [ruby-core:62737] [Bug #9861] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46098 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vsnprintf.c')
-rw-r--r--vsnprintf.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/vsnprintf.c b/vsnprintf.c
index d8e66cdbd0..f8b5a8970b 100644
--- a/vsnprintf.c
+++ b/vsnprintf.c
@@ -993,7 +993,7 @@ fp_begin: _double = va_arg(ap, double);
*/
const char *p = (char *)memchr(cp, 0, prec);
- if (p != NULL && (p - cp) > prec)
+ if (p != NULL && (p - cp) < prec)
size = (int)(p - cp);
else
size = prec;