aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/objective-c
diff options
context:
space:
mode:
Diffstat (limited to 'src/objective-c')
-rw-r--r--src/objective-c/GRPCClient/private/NSData+GRPC.m8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/objective-c/GRPCClient/private/NSData+GRPC.m b/src/objective-c/GRPCClient/private/NSData+GRPC.m
index 6487bcb589..1238374af3 100644
--- a/src/objective-c/GRPCClient/private/NSData+GRPC.m
+++ b/src/objective-c/GRPCClient/private/NSData+GRPC.m
@@ -70,8 +70,8 @@ static grpc_byte_buffer *CopyCharArrayToNewByteBuffer(const char *array,
return nil;
}
char *array;
- NSUInteger length;
- MallocAndCopyByteBufferToCharArray(buffer, (size_t *)&length, &array);
+ size_t length;
+ MallocAndCopyByteBufferToCharArray(buffer, &length, &array);
if (!array) {
// TODO(jcanizales): grpc_byte_buffer is reference-counted, so we can
// prevent this memory problem by implementing a subclass of NSData
@@ -79,7 +79,9 @@ static grpc_byte_buffer *CopyCharArrayToNewByteBuffer(const char *array,
// can be implemented using a grpc_byte_buffer_reader.
return nil;
}
- return [self dataWithBytesNoCopy:array length:length freeWhenDone:YES];
+ // Not depending upon size assumption of NSUInteger
+ NSUInteger length_max = MIN(length, UINT_MAX);
+ return [self dataWithBytesNoCopy:array length:length_max freeWhenDone:YES];
}
- (grpc_byte_buffer *)grpc_byteBuffer {