From 7d978084ca28ac8a456dbdd9d6b39e6dfc169fd9 Mon Sep 17 00:00:00 2001 From: Hiroshi Ichikawa Date: Tue, 1 May 2018 00:44:41 +0900 Subject: [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. --- objectivec/GPBCodedInputStream.m | 6 +++--- 1 file 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) { -- cgit v1.2.3