Fixed a serious bug - a race condition where a data buffer in the writer's queue could be dealloced (not the NSData, but its bytes themselves) before the writer sent it, resulting in an EFAULT error.
authorJens Alfke <jens@mooseyard.com>
Fri May 30 13:54:38 2008 -0700 (2008-05-30)
changeset 9980beba83fb7
parent 8 6f539dd9921c
child 10 a2aeb9b04ecc
Fixed a serious bug - a race condition where a data buffer in the writer's queue could be dealloced (not the NSData, but its bytes themselves) before the writer sent it, resulting in an EFAULT error.
BLIP/BLIPMessage.m
     1.1 --- a/BLIP/BLIPMessage.m	Thu May 29 16:40:36 2008 -0700
     1.2 +++ b/BLIP/BLIPMessage.m	Fri May 30 13:54:38 2008 -0700
     1.3 @@ -256,9 +256,8 @@
     1.4      
     1.5      // Then write the body:
     1.6      if( lengthToWrite > 0 ) {
     1.7 -        [writer writeData: [NSData dataWithBytesNoCopy: (UInt8*)_encodedBody.bytes + _bytesWritten
     1.8 -                                              length: lengthToWrite
     1.9 -                                        freeWhenDone: NO]];
    1.10 +        [writer writeData: [NSData dataWithBytes: (UInt8*)_encodedBody.bytes + _bytesWritten
    1.11 +                                          length: lengthToWrite]];
    1.12          _bytesWritten += lengthToWrite;
    1.13      }
    1.14      return (flags & kBLIP_MoreComing) != 0;