Skip to content

Commit 66bc46e

Browse files
Fix leaks of keys in Matter.framework unit tests.
We need to CFRelease the return from SecKeyCreateWithData, and we were not doing that.
1 parent 7f931a0 commit 66bc46e

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

src/darwin/Framework/CHIPTests/MTRCertificateValidityTests.m

+2
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,8 @@ - (void)issueOperationalCertificateForRequest:(MTROperationalCSRInfo *)csrInfo
163163

164164
__auto_type * operationalCertificate = [self issueOperationalCertificateForNode:@(kDeviceId)
165165
operationalPublicKey:operationalPublicKey];
166+
// Release no-longer-needed key key before we do anything else.
167+
CFRelease(operationalPublicKey);
166168
XCTAssertNotNil(operationalCertificate);
167169

168170
__auto_type * certChain = [[MTROperationalCertificateChain alloc] initWithOperationalCertificate:operationalCertificate

src/darwin/Framework/CHIPTests/MTRPerControllerStorageTests.m

+2
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ - (void)issueOperationalCertificateForRequest:(MTROperationalCSRInfo *)csrInfo
158158
nodeID:self.nextNodeID
159159
caseAuthenticatedTags:nil
160160
error:&error];
161+
// Release no-longer-needed key key before we do anything else.
162+
CFRelease(publicKey);
161163
XCTAssertNil(error);
162164
XCTAssertNotNil(operationalCert);
163165

0 commit comments

Comments
 (0)