Fix a couple file descriptor leaks.

This commit is contained in:
Justin Maggard 2014-01-16 13:11:54 -08:00
parent 2aedabb52c
commit a21bbe557d
2 changed files with 5 additions and 4 deletions

View File

@ -202,11 +202,10 @@ getsyshwaddr(char *buf, int len)
if (fd < 0)
continue;
strncpy(ifr.ifr_name, p->ifa_name, IFNAMSIZ);
if (ioctl(fd, SIOCGIFHWADDR, &ifr) < 0)
{
ret = ioctl(fd, SIOCGIFHWADDR, &ifr);
close(fd);
if (ret < 0)
continue;
}
memcpy(mac, ifr.ifr_hwaddr.sa_data, 6);
#else
struct sockaddr_dl *sdl;

View File

@ -771,6 +771,7 @@ SubmitServicesToMiniSSDPD(const char *host, unsigned short port)
{
DPRINTF(E_ERROR, L_SSDP, "connect(\"%s\"): %s",
minissdpdsocketpath, strerror(errno));
close(s);
return -1;
}
for (i = 0; known_service_types[i]; i++)
@ -802,6 +803,7 @@ SubmitServicesToMiniSSDPD(const char *host, unsigned short port)
if(write(s, buffer, p - buffer) < 0)
{
DPRINTF(E_ERROR, L_SSDP, "write(): %s", strerror(errno));
close(s);
return -1;
}
}