mirror of
https://github.com/microsoft/mimalloc.git
synced 2024-12-28 13:58:30 +08:00
guard against passing stdin/stderr as output
This commit is contained in:
parent
86ee1722f5
commit
9fc726619a
@ -150,6 +150,7 @@ static void mi_out_stderr(const char* msg) {
|
||||
// Default output handler
|
||||
// --------------------------------------------------------
|
||||
|
||||
#pragma warning(suppress:4180)
|
||||
static volatile _Atomic(mi_output_fun*) mi_out_default; // = NULL
|
||||
|
||||
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 (_mi_preloading() || recurse) return;
|
||||
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);
|
||||
if (prefix != NULL) out(prefix);
|
||||
out(buf);
|
||||
|
Loading…
x
Reference in New Issue
Block a user