copy_fd: close ifd on error
In copy_fd when write fails we ought to close input file descriptor. Signed-off-by: Sam Ravnborg <sam@ravnborg.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
parent
975b31dc6e
commit
08337a97a2
7
copy.c
7
copy.c
@ -22,13 +22,16 @@ int copy_fd(int ifd, int ofd)
|
||||
buf += written;
|
||||
len -= written;
|
||||
}
|
||||
else if (!written)
|
||||
else if (!written) {
|
||||
close(ifd);
|
||||
return error("copy-fd: write returned 0");
|
||||
else
|
||||
} else {
|
||||
close(ifd);
|
||||
return error("copy-fd: write returned %s",
|
||||
strerror(errno));
|
||||
}
|
||||
}
|
||||
}
|
||||
close(ifd);
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user