Save errno from close override.

Approved by:	pjd (mentor)
This commit is contained in:
oshogbo 2015-04-29 22:59:44 +00:00
parent b9b0abb325
commit 4859a065d5
2 changed files with 7 additions and 1 deletions

View File

@ -929,8 +929,10 @@ nvlist_recv(int sock)
nvl = nvlist_xunpack(buf, size, fds, nfds);
if (nvl == NULL) {
SAVE_ERRNO(serrno);
for (i = 0; i < nfds; i++)
close(fds[i]);
RESTORE_ERRNO(serrno);
goto out;
}

View File

@ -848,6 +848,7 @@ nvpair_t *
nvpair_create_descriptor(const char *name, int value)
{
nvpair_t *nvp;
int serrno;
if (value < 0 || !fd_is_valid(value)) {
errno = EBADF;
@ -860,8 +861,11 @@ nvpair_create_descriptor(const char *name, int value)
nvp = nvpair_allocv(name, NV_TYPE_DESCRIPTOR, (uint64_t)value,
sizeof(int64_t));
if (nvp == NULL)
if (nvp == NULL) {
SAVE_ERRNO(serrno);
close(value);
RESTORE_ERRNO(serrno);
}
return (nvp);
}