1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-30 12:04:07 +00:00

In __mbsconv(), if prec was zero, nconv could have been used

uninitialized.  Initialize it to a safe value so that there's no
chance of returning an error if stack garbage happens to be equal to
(size_t)-1 or (size_t)-2.

Found by:	Clang static analyzer
MFC after:	7 days
This commit is contained in:
Garrett Wollman 2009-11-25 04:27:55 +00:00
parent e40c32385d
commit ab5b2fafec
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=199782

View File

@ -293,7 +293,7 @@ __mbsconv(char *mbsarg, int prec)
* number of characters to print.
*/
p = mbsarg;
insize = nchars = 0;
insize = nchars = nconv = 0;
mbs = initial_mbs;
while (nchars != (size_t)prec) {
nconv = mbrlen(p, MB_CUR_MAX, &mbs);