keithduncan / CoreNetworking

Simple set up for building Objective-C network clients and servers, includes a simple HTTP server out of the box.
BSD 3-Clause "New" or "Revised" License
19 stars 5 forks source link

Retain and autorelease the current read before clearing it #63

Closed ddeville closed 10 years ago

ddeville commented 10 years ago

This is to prevent an issue where an instance of a packet could be release by the (last) owner – which would lead to the object being deallocated – in the middle of the performRead: message call.

This would lead to a bad access when the object attempts to access self later on in the execution of the method.

ddeville commented 10 years ago

I was only able to observe this issue in AFHTTPHeadersPacket but given that the pattern is replicated in other packet subclasses it’s probably wise to prevent a similar issue.

keithduncan commented 10 years ago

:+1: