diff options
author | Patrick Ohly <patrick.ohly@intel.com> | 2010-02-25 21:48:25 +0100 |
---|---|---|
committer | Patrick Ohly <patrick.ohly@intel.com> | 2010-02-25 21:48:25 +0100 |
commit | ec636afc6fcaf129ca65da76cddc09a2fb5e1968 (patch) | |
tree | 725a7ee163c59e30f188f5c4c06ea5a4b8d793f6 | |
parent | 904d1fb47ecd39c58f349012fd4c343d6fcf63e9 (diff) |
debuglogger: avoid segfault when log file cannot be reopened
While a SyncML server session was active, I removed the directory
and the log file that the server was using. The next time the
server tried to log something, it segfaulted in the fclose(fFile)
because of the NULL pointer from fopen().
Don't do anything if the file cannot be opened.
-rwxr-xr-x | src/sysync/debuglogger.cpp | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/sysync/debuglogger.cpp b/src/sysync/debuglogger.cpp index 00f229b..e093f8d 100755 --- a/src/sysync/debuglogger.cpp +++ b/src/sysync/debuglogger.cpp @@ -358,16 +358,17 @@ void TStdFileDbgOut::putLine(cAppCharP aLine, bool aForceFlush) // now output fputs(aLine,fFile); fputs("\n",fFile); - } - // do required flushing - if (fFlushMode==dbgflush_openclose) { - // we need to close the file after every line of output - fclose(fFile); - fFile=NULL; - } - else if (aForceFlush || fFlushMode==dbgflush_flush) { - // simply flush - fflush(fFile); + + // do required flushing + if (fFlushMode==dbgflush_openclose) { + // we need to close the file after every line of output + fclose(fFile); + fFile=NULL; + } + else if (aForceFlush || fFlushMode==dbgflush_flush) { + // simply flush + fflush(fFile); + } } } } // TStdFileDbgOut::putLine |