zeroconf/Bonjour: don't call DNSServiceRefDeallocate() if DNSServiceRegister() fails

According to
https://developer.apple.com/documentation/dnssd/1804733-dnsserviceregister
the DNSServiceRef is initialized only if DNSServiceRegister() returns
kDNSServiceErr_NoError.  The faulty error handling code could
therefore crash.
This commit is contained in:
Max Kellermann 2021-02-24 13:48:12 +01:00
parent 04d5588fe5
commit 47461df59c

View File

@ -97,11 +97,6 @@ BonjourInit(EventLoop &loop, const char *service_name, unsigned port)
if (error != kDNSServiceErr_NoError) { if (error != kDNSServiceErr_NoError) {
LogError(bonjour_domain, LogError(bonjour_domain,
"Failed to register zeroconf service"); "Failed to register zeroconf service");
if (dnsReference) {
DNSServiceRefDeallocate(dnsReference);
dnsReference = nullptr;
}
return; return;
} }