From bae87a479016504577b7def06f38615837f12b50 Mon Sep 17 00:00:00 2001 From: nobu Date: Sun, 25 May 2014 02:56:36 +0000 Subject: 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 --- vsnprintf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'vsnprintf.c') 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; -- cgit v1.2.1