diff --git a/bin/rcp/rcp.c b/bin/rcp/rcp.c index d36f3bd4181..62d7dafd330 100644 --- a/bin/rcp/rcp.c +++ b/bin/rcp/rcp.c @@ -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; }