Author: cwittich
Date: Sun Sep 7 10:34:17 2014
New Revision: 64056
URL:
http://svn.reactos.org/svn/reactos?rev=64056&view=rev
Log:
[crt]
fix behavior of _sxprintf when a NULL buffer is supplied
fixes ntdll:string winetest
Modified:
trunk/reactos/lib/sdk/crt/printf/_sxprintf.c
trunk/reactos/lib/sdk/crt/printf/streamout.c
Modified: trunk/reactos/lib/sdk/crt/printf/_sxprintf.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/printf/_sxprin…
==============================================================================
--- trunk/reactos/lib/sdk/crt/printf/_sxprintf.c [iso-8859-1] (original)
+++ trunk/reactos/lib/sdk/crt/printf/_sxprintf.c [iso-8859-1] Sun Sep 7 10:34:17 2014
@@ -57,12 +57,6 @@
int result;
FILE stream;
- /* Check trivial case */
- if ((buffer == NULL) && (count == 0) && (sizeOfBuffer == 0))
- {
- return 0;
- }
-
#if IS_SECAPI
/* Validate parameters */
if (MSVCRT_CHECK_PMT(((buffer == NULL) || (format == NULL) || (sizeOfBuffer <=
0))))
@@ -118,7 +112,8 @@
buffer[result] = _T('\0');
#else
/* 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
return result;
Modified: trunk/reactos/lib/sdk/crt/printf/streamout.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/printf/streamo…
==============================================================================
--- trunk/reactos/lib/sdk/crt/printf/streamout.c [iso-8859-1] (original)
+++ trunk/reactos/lib/sdk/crt/printf/streamout.c [iso-8859-1] Sun Sep 7 10:34:17 2014
@@ -227,6 +227,9 @@
int
streamout_char(FILE *stream, int chr)
{
+ if ((stream->_flag & _IOSTRG) && (!stream->_ptr))
+ return 1;
+
#if defined(_USER32_WSPRINTF) || defined(_LIBCNT_)
/* Check if the buffer is full */
if (stream->_cnt < sizeof(TCHAR))