[ObjC] Ensure objects aren't leaked on parsing failures.
Add the objects to the object graph and balance the retain count before doing the parsing. This ensure if an error is hit (and a throw happens), the object(s) won't be leaked. Parsing will always mutate the graph, so yes this includes more mutations in failure cases, but other fields could always be modified before the bad data is encountered. But even then, that edge case *only* apples to api users that are explicitly *merge* (-mergeFrom...), the majority of the calls are to +parseFromData:error:, so the entire graph is released on failure. PiperOrigin-RevId: 510417377
Loading
Please sign in to comment