Changeset 2569 for trunk

Show
Ignore:
Timestamp:
04/28/05 22:33:14 (4 years ago)
Author:
timothy
Message:

Fixes a reported crash (that seems rare) when incrementally writing a transcript.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/JVChatTranscript.m

    r2558 r2569  
    10251025                [_logFile seekToFileOffset:_previousLogOffset]; 
    10261026                NSData *check = [_logFile readDataOfLength:9]; // check to see if there is an <envelope> here 
    1027                 if( strncmp( "<envelope", [check bytes], 9 ) ) { // this is a bad offset! 
     1027                if( [check length] != 9 || strncmp( "<envelope", [check bytes], 9 ) ) { // this is a bad offset! 
    10281028                        _requiresNewEnvelope = YES; 
    10291029                        _previousLogOffset = 0; 
     
    10341034                [_logFile seekToFileOffset:[_logFile seekToEndOfFile] - 1]; 
    10351035                NSData *check = [_logFile readDataOfLength:1]; // check to see if there is an trailing newline and correct 
    1036                 if( ! strncmp( "\n", [check bytes], 1 ) ) offset++; // we need to eat the newline also 
     1036                if( [check length] == 1 && ! strncmp( "\n", [check bytes], 1 ) ) offset++; // we need to eat the newline also 
    10371037 
    10381038                [_logFile seekToFileOffset:[_logFile offsetInFile] - offset]; 
    10391039                check = [_logFile readDataOfLength:offset]; // check to see if there is a </log> here 
    1040                 if( strncmp( ( offset == 7 ? "</log>\n" : "</log>" ), [check bytes], offset ) ) { // this is a bad file! 
     1040                if( [check length] != offset || strncmp( ( offset == 7 ? "</log>\n" : "</log>" ), [check bytes], offset ) ) { // this is a bad file! 
    10411041                        [self setAutomaticallyWritesChangesToFile:NO]; 
    10421042                        return;