mirror of
https://github.com/reactos/reactos.git
synced 2025-05-20 17:45:06 +00:00
[crt]
fix behavior of _sxprintf when a NULL buffer is supplied fixes ntdll:string winetest svn path=/trunk/; revision=64056
This commit is contained in:
parent
b84022008b
commit
43a4a1563c
2 changed files with 5 additions and 7 deletions
|
@ -57,12 +57,6 @@ _sxprintf(
|
||||||
int result;
|
int result;
|
||||||
FILE stream;
|
FILE stream;
|
||||||
|
|
||||||
/* Check trivial case */
|
|
||||||
if ((buffer == NULL) && (count == 0) && (sizeOfBuffer == 0))
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if IS_SECAPI
|
#if IS_SECAPI
|
||||||
/* Validate parameters */
|
/* Validate parameters */
|
||||||
if (MSVCRT_CHECK_PMT(((buffer == NULL) || (format == NULL) || (sizeOfBuffer <= 0))))
|
if (MSVCRT_CHECK_PMT(((buffer == NULL) || (format == NULL) || (sizeOfBuffer <= 0))))
|
||||||
|
@ -118,7 +112,8 @@ _sxprintf(
|
||||||
buffer[result] = _T('\0');
|
buffer[result] = _T('\0');
|
||||||
#else
|
#else
|
||||||
/* Only zero terminate if there is enough space left */
|
/* Only zero terminate if there is enough space left */
|
||||||
if (stream._cnt >= sizeof(TCHAR)) *(TCHAR*)stream._ptr = _T('\0');
|
if ((stream._cnt >= sizeof(TCHAR)) && (stream._ptr))
|
||||||
|
*(TCHAR*)stream._ptr = _T('\0');
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -227,6 +227,9 @@ static
|
||||||
int
|
int
|
||||||
streamout_char(FILE *stream, int chr)
|
streamout_char(FILE *stream, int chr)
|
||||||
{
|
{
|
||||||
|
if ((stream->_flag & _IOSTRG) && (!stream->_ptr))
|
||||||
|
return 1;
|
||||||
|
|
||||||
#if defined(_USER32_WSPRINTF) || defined(_LIBCNT_)
|
#if defined(_USER32_WSPRINTF) || defined(_LIBCNT_)
|
||||||
/* Check if the buffer is full */
|
/* Check if the buffer is full */
|
||||||
if (stream->_cnt < sizeof(TCHAR))
|
if (stream->_cnt < sizeof(TCHAR))
|
||||||
|
|
Loading…
Reference in a new issue