Skip to content

Commit 3e6de54

Browse files
Do something sane-ish if someone tries to create MTRDevice with a null nodeID.
1 parent f509f67 commit 3e6de54

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/darwin/Framework/CHIP/MTRDevice.mm

+9
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,15 @@ - (void)dealloc
305305

306306
+ (MTRDevice *)deviceWithNodeID:(NSNumber *)nodeID controller:(MTRDeviceController *)controller
307307
{
308+
if (nodeID == nil || controller == nil) {
309+
// These are not nullable in our API, but clearly someone is not
310+
// actually turning on the relevant compiler checks (or is doing dynamic
311+
// dispatch with bad values). While we promise to not return nil from
312+
// this method, if the caller is ignoring the nullability API contract,
313+
// there's not much we can do here.
314+
return nil;
315+
}
316+
308317
return [controller deviceForNodeID:nodeID];
309318
}
310319

0 commit comments

Comments
 (0)