summaryrefslogtreecommitdiff
path: root/t/t4013/diff.diff_initial..side
diff options
context:
space:
mode:
authorJohannes Schindelin <johannes.schindelin@gmx.de>2026-07-05 08:24:19 +0000
committerJunio C Hamano <gitster@pobox.com>2026-07-05 09:12:09 -0700
commitbd58327406c6868b92fb1b61d85b7430839042d4 (patch)
tree80b0d8a69f5909bcefedd41b3d5ac556792e395f /t/t4013/diff.diff_initial..side
parent8b90835161cff95e80bc39e8acb25f0f77592ecf (diff)
loose: avoid closing invalid fd on error path
`write_one_object()` opens a file at line 186 and jumps to the errout label on failure. The errout cleanup unconditionally calls `close(fd)`, but when `open()` itself failed, fd is -1. Calling `close(-1)` is harmless on most platforms (returns EBADF) but is undefined behavior per POSIX and can confuse fd tracking in sanitizer builds. Guard the close with fd >= 0. Pointed out by Coverity. Assisted-by: Claude Opus 4.6 Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t4013/diff.diff_initial..side')
0 files changed, 0 insertions, 0 deletions