Skip to content

Commit

Permalink
Don't prevent passing NULL to non-Objective-C pointer parameters.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mobile-devx-github-bot committed Jul 1, 2021
1 parent 3afaeda commit c3e99d6
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions Service/Sources/EDOInvocationMessage.m
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit c3e99d6

Please sign in to comment.