Commit 32aaf9ee authored by Protobuf Team Bot's avatar Protobuf Team Bot Committed by Copybara-Service
Browse files

[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
parent bab55c25
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment