mirror of
https://github.com/git/git.git
synced 2026-01-11 21:33:13 +09:00
pack-mtimes: avoid closing a bogus file descriptor
In 94cd775a6c52 (pack-mtimes: support reading .mtimes files, 2022-05-20), code was added to close the file descriptor corresponding to the mtimes file. However, it is possible that opening that file failed, in which case we are closing a file descriptor with the value `-1`. Let's guard that `close()` call. Reported by Coverity. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
652891de4f
commit
41f1a8e6a4
@ -89,7 +89,8 @@ cleanup:
|
||||
*data_p = data;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
if (fd >= 0)
|
||||
close(fd);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user