diff options
author | Hiroshi Ichikawa <gimite@gmail.com> | 2018-05-01 00:44:41 +0900 |
---|---|---|
committer | Thomas Van Lenten <thomasvl@google.com> | 2018-04-30 11:44:41 -0400 |
commit | 7d978084ca28ac8a456dbdd9d6b39e6dfc169fd9 (patch) | |
tree | 3b994554a1a82a27396b61eef5e2e1f4dcb5676e | |
parent | fc922d16ed7ae3c19defe82228a9760f3d8d1073 (diff) | |
download | protobuf-7d978084ca28ac8a456dbdd9d6b39e6dfc169fd9.tar.gz protobuf-7d978084ca28ac8a456dbdd9d6b39e6dfc169fd9.tar.bz2 protobuf-7d978084ca28ac8a456dbdd9d6b39e6dfc169fd9.zip |
[objectivec] Fix memory leak of exceptions raised by RaiseException() (#4556)
* Fix memory leak of exceptions raised by RaiseException()
Currently exceptions raised by RaiseException() is never deallocated because:
* ARC is disabled for this library: https://github.com/google/protobuf/blob/master/BUILD#L913
* It is constructed with `+alloc` but is never `-release`d.
This change fixes the issue by using `-[NSException exceptionWithName:...]` instead, which returns an autoreleased instance, so it is deallocated properly.
* Fix format.
-rw-r--r-- | objectivec/GPBCodedInputStream.m | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/objectivec/GPBCodedInputStream.m b/objectivec/GPBCodedInputStream.m index a8262e5d..dd05ddb4 100644 --- a/objectivec/GPBCodedInputStream.m +++ b/objectivec/GPBCodedInputStream.m @@ -63,9 +63,9 @@ static void RaiseException(NSInteger code, NSString *reason) { NSDictionary *exceptionInfo = @{ GPBCodedInputStreamUnderlyingErrorKey: error }; - [[[NSException alloc] initWithName:GPBCodedInputStreamException - reason:reason - userInfo:exceptionInfo] raise]; + [[NSException exceptionWithName:GPBCodedInputStreamException + reason:reason + userInfo:exceptionInfo] raise]; } static void CheckRecursionLimit(GPBCodedInputStreamState *state) { |