Tune up Windows snprintf() support

When we build with Visual Studio in debug mode, the invalid parameter handler
aborts the application (and offers to debug it) when n is 0. We want to
just return -1 instead (as calls with n == 0 are expected and happen in our
tests).
parent fc367086
......@@ -70,6 +70,10 @@ int mbedtls_platform_win32_snprintf( char *s, size_t n, const char *fmt, ... )
int ret;
va_list argp;
/* Avoid calling the invalid parameter handler by checking ourselves */
if( s == NULL || n == 0 || fmt == NULL )
return( -1 );
va_start( argp, fmt );
ret = _vsnprintf_s( s, n, _TRUNCATE, fmt, argp );
va_end( argp );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment