Fix NPE for trying to add metadata to error when it was nil

pull/2074/head
Jorge Canizales 10 years ago
parent 0d6cf992e8
commit c58a1103b6
  1. 9
      src/objective-c/GRPCClient/GRPCCall.m

@ -319,9 +319,12 @@ NSString * const kGRPCStatusMetadataKey = @"io.grpc.StatusMetadataKey";
if (strongSelf) {
[strongSelf->_responseMetadata addEntriesFromDictionary:trailers];
NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithDictionary:error.userInfo];
userInfo[kGRPCStatusMetadataKey] = strongSelf->_responseMetadata;
error = [NSError errorWithDomain:error.domain code:error.code userInfo:userInfo];
if (error) {
NSMutableDictionary *userInfo =
[NSMutableDictionary dictionaryWithDictionary:error.userInfo];
userInfo[kGRPCStatusMetadataKey] = strongSelf->_responseMetadata;
error = [NSError errorWithDomain:error.domain code:error.code userInfo:userInfo];
}
[strongSelf finishWithError:error];
}
}];

Loading…
Cancel
Save