github/Mantle — pull request #120 by robb (2013-08-07 13:27:51+00:00)
Title: [WIP] Prevent double-deletion of managed objects

I've found an issue in MTLManagedObjectAdapter that tries to delete managedObject twice if serializing a property failed.

What happens is that [in line 450 in MTLManagedObjectAdapter.m](https://github.com/robb/Mantle/blob/83d16f0a4f76d4768932a84a6a3f97c0b2ad44d2/Mantle/MTLManagedObjectAdapter.m#L450), the model object is nilled if the serialization of the property failed, then [line 455](https://github.com/robb/Mantle/blob/83d16f0a4f76d4768932a84a6a3f97c0b2ad44d2/Mantle/MTLManagedObjectAdapter.m#L455-L460) falls through since `[nil validateForInsert:error]` is `NO`, resulting in `[context deleteObject:nil];` :boom:.

I believe I found a fix. __However__, the NSError created in [line 416](https://github.com/robb/Mantle/blob/83d16f0a4f76d4768932a84a6a3f97c0b2ad44d2/Mantle/MTLManagedObjectAdapter.m#L416) is prematurely deallocated, crashing my test.
I've verified this with NSZombiesEnabled but couldn't figure out where exactly the error is not being retained properly.