Skip to content

Commit 2ad1e9e

Browse files
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
1 parent 3afaeda commit 2ad1e9e

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

Service/Sources/EDOInvocationMessage.m

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,9 +279,16 @@ + (instancetype)requestWithInvocation:(NSInvocation *)invocation
279279
value = objRef ? BOX_VALUE(*objRef, target, service, nil)
280280
: [EDOBoxedValueType parameterForDoublePointerNullValue];
281281
} else if (EDO_IS_POINTER(ctype)) {
282-
// TODO(haowoo): Add the proper error and/or exception handler.
283-
NSAssert(NO, @"Not supported type (%s) in the argument for selector (%@).", ctype,
284-
selector ? NSStringFromSelector(selector) : @"(block)");
282+
void *objRef;
283+
[invocation getArgument:&objRef atIndex:i];
284+
285+
// Don't assert if the pointer is NULL.
286+
if (objRef != NULL) {
287+
// TODO(haowoo): Add the proper error and/or exception handler.
288+
NSAssert(NO, @"Not supported type (%s) in argument %@ for selector (%@).", ctype, @(i),
289+
selector ? NSStringFromSelector(selector) : @"(block)");
290+
}
291+
value = [EDOBoxedValueType parameterForNilValue];
285292
} else {
286293
NSUInteger typeSize = 0L;
287294
NSGetSizeAndAlignment(ctype, &typeSize, NULL);

0 commit comments

Comments
 (0)