robbiehanson/CocoaLumberjack — Issue #11: crash on deallocated NSFileHandle in DDFileLogger
Author: waggyza
Created: 2011-12-03 11:46:05+00:00
State: open

- (NSFileHandle *)currentLogFileHandle creates a fileHandleForWritingAtPath (line 735) but does not retain this handle, so on the second call of
- (void)logMessage:(DDLogMessage *)logMessage the statement [[self currentLogFileHandle] writeData:logData]; (line 769) crashes as follows:
-[NSConcreteFileHandle writeData:]: message sent to deallocated instance 0x8db6110

Based on this I believe the correction for this is to change line 735 to add a retain as follows:
currentLogFileHandle = [[NSFileHandle fileHandleForWritingAtPath:logFilePath] retain];

Then currentLogFileHandle will also need to be released after the file is closed in
- (void)dealloc
and
- (void)rollLogFileNow

Regards,

Dan