Hi Experts,
I created a simple application with the following code to retrieve the proxy info based on PAC file or PAC URL such as Xcode:
NSString *strURL = @"http://example.com";
NSString *pacFileData = @"function FindProxyForURL(url, host) {if (dnsDomainIs(host, \"example.com\") || dnsDomainIs(host, \"www.example.com\")) {return \"PROXY 192.168.1.2:8888;DIRECT\";}return \"DIRECT\";}";
CFStringRef tempPacdata = CFStringCreateCopy(kCFAllocatorDefault, (__bridge CFStringRef)pacFileData);
CFURLRef tempURLref = CFURLCreateWithString(kCFAllocatorDefault, (__bridge CFStringRef)strURL, nil);
CFArrayRef proxies = CFNetworkCopyProxiesForAutoConfigurationScript(tempPacdata, tempURLref, &err);
strURL = nil;
if (proxies != NULL)
{
CFRelease(proxies);
proxies = NULL;
}
if (tempPacdata != NULL)
{
CFRelease(tempPacdata);
tempPacdata = NULL;
}
if (tempURLref != NULL)
{
CFRelease(tempURLref);
tempURLref = NULL;
}
The output of leaks:
Report Version: 7
Analysis Tool: /usr/bin/leaks
Physical footprint: 2700K
Physical footprint (peak): 2700K
----
leaks Report Version: 4.0
Process 43271: 783 nodes malloced for 85 KB
Process 43271: 17 leaks for 1232 total leaked bytes.
17 (1.20K) ROOT CYCLE: <CFRunLoopSource 0x6000002f8000> [192]
16 (1.02K) ROOT CYCLE: 0x600000ef80e0 [224]
CYCLE BACK TO <CFRunLoopSource 0x6000002f8000> [192]
5 (352 bytes) ROOT CYCLE: 0x6000019f4400 [128]
2 (80 bytes) ROOT CYCLE: 0x6000037e8220 [32]
1 (48 bytes) ROOT CYCLE: <__NSMallocBlock__ 0x6000039e8030> [48] CFNetwork <unknown-symbol> 0x7ff819c39000 + 1605859 0x7ff819dc10e3
1 (32 bytes) ROOT CYCLE: 0x6000037e8240 [32]
1 (112 bytes) <NSURL 0x600001cf4000> [112] "http://example.com/"
9 (432 bytes) <CFArray 0x6000022f87c0> [64] item count: 2
5 (240 bytes) <NSDictionary 0x6000022f8780> [64] item count: 3
1 (48 bytes) <CFString 0x6000039f8c60> [48] length: 16 "kCFProxyTypeHTTP"
1 (48 bytes) <CFString 0x6000039f8d50> [48] length: 21 "kCFProxyPortNumberKey"
1 (48 bytes) _list --> <CFString 0x6000039f8cf0> [48] length: 19 "kCFProxyHostNameKey"
1 (32 bytes) <CFString 0x6000037fab00> [32] length: 11 "192.168.1.2"
3 (128 bytes) <NSDictionary 0x6000037fab20> [32]
1 (48 bytes) _key --> <CFString 0x6000039f8c00> [48] length: 15 "kCFProxyTypeKey"
1 (48 bytes) _obj --> <CFString 0x6000039f8cc0> [48] length: 16 "kCFProxyTypeNone"
1 (32 bytes) 0x6000037fab40 [32]
Does that mean some bugs in those APIs?