mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-01-05 12:44:10 +00:00
fix memory leak in macos ipv6/dns helper (#2030)
Co-authored-by: Grant Limberg <glimberg@users.noreply.github.com>
This commit is contained in:
parent
1ce08a62a9
commit
6540107ccb
@ -122,21 +122,16 @@ bool MacDNSHelper::addIps(uint64_t nwid, const MAC mac, const char *dev, const s
|
|||||||
|
|
||||||
|
|
||||||
CFStringRef key = CFStringCreateWithCString(NULL, buf, kCFStringEncodingUTF8);
|
CFStringRef key = CFStringCreateWithCString(NULL, buf, kCFStringEncodingUTF8);
|
||||||
CFStringRef* cfaddrs = new CFStringRef[1];
|
|
||||||
CFStringRef* cfprefixes = new CFStringRef[1];
|
|
||||||
CFStringRef* cfdestaddrs = new CFStringRef[1];
|
|
||||||
CFStringRef* cfflags = new CFStringRef[1];
|
|
||||||
|
|
||||||
|
CFStringRef cfaddr = CFStringCreateWithCString(NULL, llStr, kCFStringEncodingUTF8);
|
||||||
|
CFStringRef cfprefixes = CFStringCreateWithCString(NULL, "64", kCFStringEncodingUTF8);
|
||||||
|
CFStringRef cfdestaddrs = CFStringCreateWithCString(NULL, "::ffff:ffff:ffff:ffff:0:0", kCFStringEncodingUTF8);
|
||||||
|
CFStringRef cfflags = CFStringCreateWithCString(NULL, "0", kCFStringEncodingUTF8);
|
||||||
|
|
||||||
cfaddrs[0] = CFStringCreateWithCString(NULL, llStr, kCFStringEncodingUTF8);
|
CFArrayRef addrArray = CFArrayCreate(NULL, (const void**)&cfaddr, 1, &kCFTypeArrayCallBacks);
|
||||||
cfprefixes[0] = CFStringCreateWithCString(NULL, "64", kCFStringEncodingUTF8);
|
CFArrayRef prefixArray = CFArrayCreate(NULL, (const void**)&cfprefixes, 1, &kCFTypeArrayCallBacks);
|
||||||
cfdestaddrs[0] = CFStringCreateWithCString(NULL, "::ffff:ffff:ffff:ffff:0:0", kCFStringEncodingUTF8);
|
CFArrayRef destArray = CFArrayCreate(NULL, (const void**)&cfdestaddrs, 1, &kCFTypeArrayCallBacks);
|
||||||
cfflags[0] = CFStringCreateWithCString(NULL, "0", kCFStringEncodingUTF8);
|
CFArrayRef flagsArray = CFArrayCreate(NULL, (const void**)&cfflags, 1, &kCFTypeArrayCallBacks);
|
||||||
|
|
||||||
CFArrayRef addrArray = CFArrayCreate(NULL, (const void**)cfaddrs, 1, &kCFTypeArrayCallBacks);
|
|
||||||
CFArrayRef prefixArray = CFArrayCreate(NULL, (const void**)cfprefixes, 1, &kCFTypeArrayCallBacks);
|
|
||||||
CFArrayRef destArray = CFArrayCreate(NULL, (const void**)cfdestaddrs, 1, &kCFTypeArrayCallBacks);
|
|
||||||
CFArrayRef flagsArray = CFArrayCreate(NULL, (const void**)cfflags, 1, &kCFTypeArrayCallBacks);
|
|
||||||
CFStringRef cfdev = CFStringCreateWithCString(NULL, dev, kCFStringEncodingUTF8);
|
CFStringRef cfdev = CFStringCreateWithCString(NULL, dev, kCFStringEncodingUTF8);
|
||||||
|
|
||||||
const int SIZE = 5;
|
const int SIZE = 5;
|
||||||
@ -182,6 +177,14 @@ bool MacDNSHelper::addIps(uint64_t nwid, const MAC mac, const char *dev, const s
|
|||||||
fprintf(stderr, "Error writing IPv6 configuration\n");
|
fprintf(stderr, "Error writing IPv6 configuration\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (oldAddrs != NULL) {
|
||||||
|
CFRelease(oldAddrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
CFRelease(cfaddr);
|
||||||
|
CFRelease(cfprefixes);
|
||||||
|
CFRelease(cfdestaddrs);
|
||||||
|
CFRelease(cfflags);
|
||||||
|
|
||||||
CFRelease(addrArray);
|
CFRelease(addrArray);
|
||||||
CFRelease(prefixArray);
|
CFRelease(prefixArray);
|
||||||
@ -189,16 +192,15 @@ bool MacDNSHelper::addIps(uint64_t nwid, const MAC mac, const char *dev, const s
|
|||||||
CFRelease(flagsArray);
|
CFRelease(flagsArray);
|
||||||
CFRelease(cfdev);
|
CFRelease(cfdev);
|
||||||
|
|
||||||
CFRelease(list);
|
|
||||||
CFRelease(dict);
|
|
||||||
|
|
||||||
CFRelease(ds);
|
CFRelease(ds);
|
||||||
CFRelease(key);
|
CFRelease(key);
|
||||||
|
|
||||||
delete[] cfaddrs;
|
// for (unsigned int i = 0; i < SIZE; ++i) {
|
||||||
delete[] cfprefixes;
|
// values[i] = NULL;
|
||||||
delete[] cfdestaddrs;
|
// }
|
||||||
delete[] cfflags;
|
|
||||||
|
CFRelease(list);
|
||||||
|
CFRelease(dict);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user