[SDK] Do not use a NUL file while calculating format string length

CORE-14342
This commit is contained in:
Mark Jansen 2018-03-08 21:38:40 +01:00
parent dedd08c38d
commit 2f548599a4
No known key found for this signature in database
GPG key ID: B39240EE84BEAE8B
2 changed files with 10 additions and 19 deletions

View file

@ -15,14 +15,9 @@ _vscprintf(
const char *format,
va_list argptr)
{
int ret;
FILE* nulfile = fopen("nul", "w");
if(nulfile == NULL)
{
/* This should never happen... */
return -1;
}
ret = streamout(nulfile, format, argptr);
fclose(nulfile);
return ret;
FILE nulfile;
nulfile._tmpfname = nulfile._ptr = nulfile._base = NULL;
nulfile._bufsiz = nulfile._charbuf = nulfile._cnt = 0;
nulfile._flag = _IOSTRG | _IOWRT;
return streamout(&nulfile, format, argptr);
}

View file

@ -22,15 +22,11 @@ _vscwprintf(
{
int ret;
#ifndef _LIBCNT_
FILE* nulfile;
nulfile = fopen("nul", "w");
if(nulfile == NULL)
{
/* This should never happen... */
return -1;
}
ret = wstreamout(nulfile, format, argptr);
fclose(nulfile);
FILE nulfile;
nulfile._tmpfname = nulfile._ptr = nulfile._base = NULL;
nulfile._bufsiz = nulfile._charbuf = nulfile._cnt = 0;
nulfile._flag = _IOSTRG | _IOWRT;
ret = wstreamout(&nulfile, format, argptr);
#else
ret = -1;
#endif