Skip to content

Commit be0fa7e

Browse files
committed
Add comments
1 parent 8a645f0 commit be0fa7e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

pkg/inventory/systeminfo/systeminfo_darwin.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,14 @@ 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);
55-
free(region);
5656
} else if (modelNum) {
5757
info.modelNumber = modelNum;
5858
}
59+
// Always free region (should be safe if NULL)
60+
free(region);
5961
}
6062

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

0 commit comments

Comments
 (0)