summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8be707d)
raw | patch | inline | side by side (parent: 8be707d)
author | Sergey Vlasov <vsu@altlinux.ru> | |
Fri, 23 Sep 2005 12:28:28 +0000 (16:28 +0400) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Fri, 23 Sep 2005 21:30:45 +0000 (14:30 -0700) |
After open() failure, copy_file() called close(ifd) with ifd == -1
(harmless, but causes Valgrind noise). The same thing was possible
for the destination file descriptor.
Signed-off-by: Sergey Vlasov <vsu@altlinux.ru>
Signed-off-by: Junio C Hamano <junkio@cox.net>
(harmless, but causes Valgrind noise). The same thing was possible
for the destination file descriptor.
Signed-off-by: Sergey Vlasov <vsu@altlinux.ru>
Signed-off-by: Junio C Hamano <junkio@cox.net>
local-fetch.c | patch | blob | history |
diff --git a/local-fetch.c b/local-fetch.c
index b3947a96574774c6a2aa17fa4f181a8b6c55838f..a3e35f9c81730ec149bf37cb19d7dbb4570a3197 100644 (file)
--- a/local-fetch.c
+++ b/local-fetch.c
void *map;
ifd = open(source, O_RDONLY);
if (ifd < 0 || fstat(ifd, &st) < 0) {
- close(ifd);
+ if (ifd >= 0)
+ close(ifd);
fprintf(stderr, "cannot open %s\n", source);
return -1;
}
status = ((ofd < 0) ||
(write(ofd, map, st.st_size) != st.st_size));
munmap(map, st.st_size);
- close(ofd);
+ if (ofd >= 0)
+ close(ofd);
if (status)
fprintf(stderr, "cannot write %s\n", dest);
else