mirror of
https://github.com/zeek/zeek.git
synced 2025-10-07 17:18:20 +00:00
Fixing potential segfault in DebugLogger.
The Reporter may not have been initialized yet when the logger ctor runs.
This commit is contained in:
parent
1a46d78584
commit
e9bd122f8a
1 changed files with 11 additions and 2 deletions
|
@ -25,10 +25,19 @@ DebugLogger::DebugLogger(const char* filename)
|
||||||
if ( filename )
|
if ( filename )
|
||||||
{
|
{
|
||||||
filename = log_file_name(filename);
|
filename = log_file_name(filename);
|
||||||
|
|
||||||
file = fopen(filename, "w");
|
file = fopen(filename, "w");
|
||||||
if ( ! file )
|
if ( ! file )
|
||||||
reporter->FatalError("can't open '%s' for debugging output.", filename);
|
{
|
||||||
|
// The reporter may not be initialized here yet.
|
||||||
|
if ( reporter )
|
||||||
|
reporter->FatalError("can't open '%s' for debugging output", filename);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf(stderr, "can't open '%s' for debugging output\n", filename);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
setvbuf(file, NULL, _IOLBF, 0);
|
setvbuf(file, NULL, _IOLBF, 0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue