commit-graph: close file before returning NULL
commitc0befa0c033b2754b93a666fe0e925c080b7d64b
authorKleber Tarcísio <klebertarcisio@yahoo.com.br>
Mon, 18 Apr 2022 17:13:27 +0000 (18 17:13 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 20 Apr 2022 20:56:24 +0000 (20 13:56 -0700)
tree83d0313388a53a054de5cc9161ca3a59726e55a5
parent6cd33dceed60949e2dbc32e3f0f5e67c4c882e1e
commit-graph: close file before returning NULL

There are two reasons that we could return NULL early within
load_commit_graph_chain():

 1. The file does not exist, so the file pointer is NULL.
 2. The file exists, but is too small to contain a single hash.

These were grouped together when the function was first written in
5c84b3396 (commit-graph: load commit-graph chains, 2019-06-18) in order
to simplify how the 'chain_name' string is freed. However, the current
code leaves a narrow window where the file pointer is not closed when
the file exists, but is rejected for being too small.

Split out these cases separately to ensure we close the file in this
case.

Signed-off-by: Kleber Tarcísio <klebertarcisio@yahoo.com.br>
Signed-off-by: Derrick Stolee <derrickstolee@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
commit-graph.c