taquitos / JLObjectMapping

Simple JSON to object and object to JSON mapping inspired by Jackson JSON Processor for Java.
MIT License
5 stars 3 forks source link

Exceptions aren't safe in ARC #7

Closed taquitos closed 9 years ago

taquitos commented 9 years ago

Wrap the NSJSONSerialization class in a non-arc compiled class and use that instead of directly catching it in JLObjectDeserializer -_objectWithString:targetClass:

taquitos commented 9 years ago

The bug is that exceptions thrown and caught in ARC code causes leaks of any __strong variables in the @try{} scope when exceptions are thrown. In this case, we're unlikely to hit an exception (so far only hit one for invalid JSON). Two approaches:

  1. allow NSJSONSerialization to throw exception and bomb app * annoying but pretty unlikely to ever happen
  2. wrap class in non-arc class * This would be annoying because to use JLObjectMapping, one would need to specifically add the "-fno-objc-arc" flag to one single file in the build settings after copying the source.
taquitos commented 9 years ago

fixed in 690be854a2897e5735d40b6eef5a5c145ed8d8bf just passing the exception through.