Skip to content

Commit 2b81db0

Browse files
committed
Add comments
1 parent 8a645f0 commit 2b81db0

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

pkg/inventory/systeminfo/systeminfo_darwin.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,15 @@ DeviceInfo getDeviceInfo(void) {
5050
char *modelNum = copyStringProperty(platform, @"model-number");
5151
char *region = copyStringProperty(platform, @"region-info");
5252
if (modelNum && region) {
53+
// info.modelNumber should be NULL in call to asprintf to avoid memory leak
5354
asprintf(&info.modelNumber, "%s%s", modelNum, region);
5455
free(modelNum);
5556
free(region);
5657
} else if (modelNum) {
5758
info.modelNumber = modelNum;
5859
}
60+
// Always free region (should be safe if NULL)
61+
free(region);
5962
}
6063

6164
NSDictionary *product = getServiceProperties(IOServiceNameMatching("product"));

0 commit comments

Comments
 (0)