From c3e99d6ff3f93b76a9e154421c482831b1bfed9e Mon Sep 17 00:00:00 2001 From: Mobile DevX Robot Date: Wed, 30 Jun 2021 14:17:16 -0700 Subject: [PATCH] Don't prevent passing NULL to non-Objective-C pointer parameters. The purpose for disallowing non-Objective-C pointer parameters is because there's no way to know how big a C pointer's underlying data is. But if the pointer is NULL, then there's nothing to pass, so just pass NULL and don't throw an exception. PiperOrigin-RevId: 382383417 --- Service/Sources/EDOInvocationMessage.m | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Service/Sources/EDOInvocationMessage.m b/Service/Sources/EDOInvocationMessage.m index b3cf94d..e119d3f 100644 --- a/Service/Sources/EDOInvocationMessage.m +++ b/Service/Sources/EDOInvocationMessage.m @@ -279,9 +279,16 @@ + (instancetype)requestWithInvocation:(NSInvocation *)invocation value = objRef ? BOX_VALUE(*objRef, target, service, nil) : [EDOBoxedValueType parameterForDoublePointerNullValue]; } else if (EDO_IS_POINTER(ctype)) { - // TODO(haowoo): Add the proper error and/or exception handler. - NSAssert(NO, @"Not supported type (%s) in the argument for selector (%@).", ctype, - selector ? NSStringFromSelector(selector) : @"(block)"); + void *objRef; + [invocation getArgument:&objRef atIndex:i]; + + // Don't assert if the pointer is NULL. + if (objRef != NULL) { + // TODO(haowoo): Add the proper error and/or exception handler. + NSAssert(NO, @"Not supported type (%s) in argument %@ for selector (%@).", ctype, @(i), + selector ? NSStringFromSelector(selector) : @"(block)"); + } + value = [NSNull null]; } else { NSUInteger typeSize = 0L; NSGetSizeAndAlignment(ctype, &typeSize, NULL);