vsprintf: fix special yet useful case for vsprintf where n < 1.

reported by jaldhar.
This commit is contained in:
Ben Gras 2010-07-22 22:35:44 +00:00
parent 6c2c2f3c34
commit c4bb6abc2b

View file

@ -21,8 +21,10 @@ vsnprintf(char *s, size_t n, const char *format, va_list arg)
tmp_stream._count = n-1;
retval = _doprnt(format, arg, &tmp_stream);
tmp_stream._count = 1;
(void) putc('\0',&tmp_stream);
if(n > 0) {
tmp_stream._count = 1;
(void) putc('\0',&tmp_stream);
}
return retval;
}