mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-05-05 23:19:31 +03:00
guard against passing stdin/stderr as output
This commit is contained in:
parent
86ee1722f5
commit
9fc726619a
1 changed files with 2 additions and 1 deletions
|
@ -150,6 +150,7 @@ static void mi_out_stderr(const char* msg) {
|
||||||
// Default output handler
|
// Default output handler
|
||||||
// --------------------------------------------------------
|
// --------------------------------------------------------
|
||||||
|
|
||||||
|
#pragma warning(suppress:4180)
|
||||||
static volatile _Atomic(mi_output_fun*) mi_out_default; // = NULL
|
static volatile _Atomic(mi_output_fun*) mi_out_default; // = NULL
|
||||||
|
|
||||||
static mi_output_fun* mi_out_get_default(void) {
|
static mi_output_fun* mi_out_get_default(void) {
|
||||||
|
@ -179,7 +180,7 @@ static void mi_vfprintf( mi_output_fun* out, const char* prefix, const char* fmt
|
||||||
if (fmt==NULL) return;
|
if (fmt==NULL) return;
|
||||||
if (_mi_preloading() || recurse) return;
|
if (_mi_preloading() || recurse) return;
|
||||||
recurse = true;
|
recurse = true;
|
||||||
if (out==NULL) out = mi_out_get_default();
|
if (out==NULL || (FILE*)out==stdout || (FILE*)out==stderr) out = mi_out_get_default();
|
||||||
vsnprintf(buf,sizeof(buf)-1,fmt,args);
|
vsnprintf(buf,sizeof(buf)-1,fmt,args);
|
||||||
if (prefix != NULL) out(prefix);
|
if (prefix != NULL) out(prefix);
|
||||||
out(buf);
|
out(buf);
|
||||||
|
|
Loading…
Add table
Reference in a new issue