From: Michael R Sweet Date: Sat, 17 Jun 2017 03:15:47 +0000 (-0400) Subject: Fix crashes on Linux (Issue #5022) X-Git-Tag: v2.2.4~22 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=de4966cb9be6a70609128bef9895fb04d6a845bb;p=thirdparty%2Fcups.git Fix crashes on Linux (Issue #5022) --- diff --git a/Makedefs.in b/Makedefs.in index 2edb13f46f..f958c263f3 100644 --- a/Makedefs.in +++ b/Makedefs.in @@ -149,7 +149,7 @@ IPPFIND_MAN = @IPPFIND_MAN@ LDFLAGS = -L../cgi-bin -L../cups -L../filter -L../ppdc \ -L../scheduler @LDARCHFLAGS@ \ @LDFLAGS@ @RELROFLAGS@ @PIEFLAGS@ $(OPTIM) -LINKCUPS = @LINKCUPS@ $(LIBGSSAPI) $(DNSSDLIBS) $(LIBZ) +LINKCUPS = @LINKCUPS@ $(LIBGSSAPI) $(DNSSDLIBS) $(SSLLIBS) $(LIBZ) LINKCUPSIMAGE = @LINKCUPSIMAGE@ LIBS = $(LINKCUPS) $(COMMONLIBS) ONDEMANDFLAGS = @ONDEMANDFLAGS@ diff --git a/cups/dest.c b/cups/dest.c index f5b0fb4028..1b62643f9c 100644 --- a/cups/dest.c +++ b/cups/dest.c @@ -1324,28 +1324,37 @@ cupsEnumDests( enum_finished: #if defined(HAVE_DNSSD) || defined(HAVE_AVAHI) + cupsArrayDelete(data.devices); + # ifdef HAVE_DNSSD - DNSServiceRefDeallocate(ipp_ref); - DNSServiceRefDeallocate(local_ipp_ref); + if (ipp_ref) + DNSServiceRefDeallocate(ipp_ref); + if (local_ipp_ref) + DNSServiceRefDeallocate(local_ipp_ref); # ifdef HAVE_SSL - DNSServiceRefDeallocate(ipp_ref); - DNSServiceRefDeallocate(local_ipp_ref); + if (ipps_ref) + DNSServiceRefDeallocate(ipps_ref); + if (local_ipps_ref) + DNSServiceRefDeallocate(local_ipps_ref); # endif /* HAVE_SSL */ - DNSServiceRefDeallocate(data.main_ref); + if (data.main_ref) + DNSServiceRefDeallocate(data.main_ref); # else /* HAVE_AVAHI */ - avahi_service_browser_free(ipp_ref); + if (ipp_ref) + avahi_service_browser_free(ipp_ref); # ifdef HAVE_SSL - avahi_service_browser_free(ipps_ref); + if (ipps_ref) + avahi_service_browser_free(ipps_ref); # endif /* HAVE_SSL */ - avahi_client_free(data.client); - avahi_simple_poll_free(data.simple_poll); + if (data.client) + avahi_client_free(data.client); + if (data.simple_poll) + avahi_simple_poll_free(data.simple_poll); # endif /* HAVE_DNSSD */ - - cupsArrayDelete(data.devices); #endif /* HAVE_DNSSD || HAVE_AVAHI */ return (1);