[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, const char *format,
va_list argptr) va_list argptr)
{ {
int ret; FILE nulfile;
FILE* nulfile = fopen("nul", "w"); nulfile._tmpfname = nulfile._ptr = nulfile._base = NULL;
if(nulfile == NULL) nulfile._bufsiz = nulfile._charbuf = nulfile._cnt = 0;
{ nulfile._flag = _IOSTRG | _IOWRT;
/* This should never happen... */ return streamout(&nulfile, format, argptr);
return -1;
}
ret = streamout(nulfile, format, argptr);
fclose(nulfile);
return ret;
} }

View file

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