Fix leaks of keys in Matter.framework unit tests. (#33276)
* Fix leaks of keys in Matter.framework unit tests.
We need to CFRelease the return from SecKeyCreateWithData, and we were not doing that.
* Address review comment.
diff --git a/src/darwin/Framework/CHIPTests/MTRCertificateValidityTests.m b/src/darwin/Framework/CHIPTests/MTRCertificateValidityTests.m
index 7a66d29..65313e9 100644
--- a/src/darwin/Framework/CHIPTests/MTRCertificateValidityTests.m
+++ b/src/darwin/Framework/CHIPTests/MTRCertificateValidityTests.m
@@ -163,6 +163,8 @@
__auto_type * operationalCertificate = [self issueOperationalCertificateForNode:@(kDeviceId)
operationalPublicKey:operationalPublicKey];
+ // Release no-longer-needed key before we do anything else.
+ CFRelease(operationalPublicKey);
XCTAssertNotNil(operationalCertificate);
__auto_type * certChain = [[MTROperationalCertificateChain alloc] initWithOperationalCertificate:operationalCertificate
diff --git a/src/darwin/Framework/CHIPTests/MTRPerControllerStorageTests.m b/src/darwin/Framework/CHIPTests/MTRPerControllerStorageTests.m
index 3c6ebfd..19f114f 100644
--- a/src/darwin/Framework/CHIPTests/MTRPerControllerStorageTests.m
+++ b/src/darwin/Framework/CHIPTests/MTRPerControllerStorageTests.m
@@ -158,6 +158,8 @@
nodeID:self.nextNodeID
caseAuthenticatedTags:nil
error:&error];
+ // Release no-longer-needed key before we do anything else.
+ CFRelease(publicKey);
XCTAssertNil(error);
XCTAssertNotNil(operationalCert);