Index: src/OFStream.m ================================================================== --- src/OFStream.m +++ src/OFStream.m @@ -1448,14 +1448,23 @@ return size; } - (size_t)writeData: (OFData *)data { - size_t length = [data count] * [data itemSize]; + void *pool; + size_t length; + + if (data == nil) + @throw [OFInvalidArgumentException exception]; + + pool = objc_autoreleasePoolPush(); + length = [data count] * [data itemSize]; [self writeBuffer: [data items] length: length]; + + objc_autoreleasePoolPop(pool); return length; } - (size_t)writeString: (OFString *)string @@ -1465,14 +1474,23 @@ } - (size_t)writeString: (OFString *)string encoding: (of_string_encoding_t)encoding { - size_t length = [string cStringLengthWithEncoding: encoding]; + void *pool; + size_t length; + + if (string == nil) + @throw [OFInvalidArgumentException exception]; + + pool = objc_autoreleasePoolPush(); + length = [string cStringLengthWithEncoding: encoding]; [self writeBuffer: [string cStringWithEncoding: encoding] length: length]; + + objc_autoreleasePoolPop(pool); return length; } - (size_t)writeLine: (OFString *)string