ucrtbase: Always return the full string length in __stdio_common_vs[w]printf for a NULL buffer.
If the target is a NULL buffer (with a zero length), we should always return the full size the format would have needed, even if UCRTBASE_PRINTF_STANDARD_SNPRINTF_BEHAVIOUR isn't specified. Signed-off-by: Martin Storsjo <martin@martin.st> Signed-off-by: Piotr Caban <piotr@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
29a0537d91
commit
ee32799d61
|
@ -764,6 +764,8 @@ int CDECL MSVCRT__stdio_common_vsprintf( unsigned __int64 options, char *str, MS
|
|||
&ctx, format, locale, options & UCRTBASE_PRINTF_MASK, arg_clbk_valist, NULL, &valist);
|
||||
puts_clbk_str_a(&ctx, 1, &nullbyte);
|
||||
|
||||
if(!str)
|
||||
return ret;
|
||||
if(options & UCRTBASE_PRINTF_LEGACY_VSPRINTF_NULL_TERMINATION)
|
||||
return ret>len ? -1 : ret;
|
||||
if(ret>=len) {
|
||||
|
@ -1282,6 +1284,8 @@ int CDECL MSVCRT__stdio_common_vswprintf( unsigned __int64 options,
|
|||
&ctx, format, locale, options & UCRTBASE_PRINTF_MASK, arg_clbk_valist, NULL, &valist);
|
||||
puts_clbk_str_w(&ctx, 1, &nullbyte);
|
||||
|
||||
if(!str)
|
||||
return ret;
|
||||
if(options & UCRTBASE_PRINTF_LEGACY_VSPRINTF_NULL_TERMINATION)
|
||||
return ret>len ? -1 : ret;
|
||||
if(ret>=len) {
|
||||
|
|
|
@ -215,6 +215,10 @@ static void test_snprintf (void)
|
|||
|
||||
ok (vsprintf_wrapper (UCRTBASE_PRINTF_STANDARD_SNPRINTF_BEHAVIOUR, NULL, 0, "abcd") == 4,
|
||||
"Failure to snprintf to NULL\n");
|
||||
ok (vsprintf_wrapper (UCRTBASE_PRINTF_LEGACY_VSPRINTF_NULL_TERMINATION, NULL, 0, "abcd") == 4,
|
||||
"Failure to snprintf to NULL\n");
|
||||
ok (vsprintf_wrapper (0, NULL, 0, "abcd") == 4,
|
||||
"Failure to snprintf to NULL\n");
|
||||
}
|
||||
|
||||
static int WINAPIV vswprintf_wrapper(unsigned __int64 options, wchar_t *str,
|
||||
|
@ -289,6 +293,13 @@ static void test_swprintf (void)
|
|||
ok (buffer[valid] == '\0',
|
||||
"\"%s\": Missing null termination (ret %d) - is %d\n", narrow_fmt, n, buffer[valid]);
|
||||
}
|
||||
|
||||
ok (vswprintf_wrapper (UCRTBASE_PRINTF_STANDARD_SNPRINTF_BEHAVIOUR, NULL, 0, str_short) == 5,
|
||||
"Failure to swprintf to NULL\n");
|
||||
ok (vswprintf_wrapper (UCRTBASE_PRINTF_LEGACY_VSPRINTF_NULL_TERMINATION, NULL, 0, str_short) == 5,
|
||||
"Failure to swprintf to NULL\n");
|
||||
ok (vswprintf_wrapper (0, NULL, 0, str_short) == 5,
|
||||
"Failure to swprintf to NULL\n");
|
||||
}
|
||||
|
||||
static int WINAPIV vfprintf_wrapper(FILE *file,
|
||||
|
|
Loading…
Reference in New Issue