vsprintf: fix special yet useful case for vsprintf where n < 1.
reported by jaldhar.
This commit is contained in:
parent
6c2c2f3c34
commit
c4bb6abc2b
1 changed files with 4 additions and 2 deletions
|
@ -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);
|
||||
if(n > 0) {
|
||||
tmp_stream._count = 1;
|
||||
(void) putc('\0',&tmp_stream);
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue