From 47461df59c906f44fd0be51d78a9c9ee2238cd36 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 24 Feb 2021 13:48:12 +0100 Subject: [PATCH] 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. --- src/zeroconf/Bonjour.cxx | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/zeroconf/Bonjour.cxx b/src/zeroconf/Bonjour.cxx index b7a5eeb64..9fd70dc3c 100644 --- a/src/zeroconf/Bonjour.cxx +++ b/src/zeroconf/Bonjour.cxx @@ -97,11 +97,6 @@ BonjourInit(EventLoop &loop, const char *service_name, unsigned port) if (error != kDNSServiceErr_NoError) { LogError(bonjour_domain, "Failed to register zeroconf service"); - - if (dnsReference) { - DNSServiceRefDeallocate(dnsReference); - dnsReference = nullptr; - } return; }