In the error handling path, don't call close(fd) if the error we're

handling is that fd = open(foo) is -1.  This bug is harmless since
close(-1) just returns an error (which the code ignores).

Found by:	Coverity Prevent(tm)
CID:		1503 (in userland test run)
This commit is contained in:
cperciva 2007-05-22 04:21:00 +00:00
parent f4c0271704
commit e4c186657b

View File

@ -403,7 +403,8 @@ syserr: run_err("%s: %s", name, strerror(errno));
if (response() < 0)
goto next;
if ((bp = allocbuf(&buffer, fd, BUFSIZ)) == NULL) {
next: (void)close(fd);
next: if (fd >= 0)
(void)close(fd);
continue;
}