mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-11 16:34:33 +00:00
filter: close the descriptor in case of error
When we hit an error writing to the next stream from a file, we jump to 'done' which currently skips over closing the file descriptor. Make sure to close the descriptor if it has been set to a valid value.
This commit is contained in:
parent
969d4b703c
commit
0137aba568
@ -887,7 +887,7 @@ int git_filter_list_stream_file(
|
|||||||
git_vector filter_streams = GIT_VECTOR_INIT;
|
git_vector filter_streams = GIT_VECTOR_INIT;
|
||||||
git_writestream *stream_start;
|
git_writestream *stream_start;
|
||||||
ssize_t readlen;
|
ssize_t readlen;
|
||||||
int fd, error;
|
int fd = -1, error;
|
||||||
|
|
||||||
if ((error = stream_list_init(
|
if ((error = stream_list_init(
|
||||||
&stream_start, &filter_streams, filters, target)) < 0 ||
|
&stream_start, &filter_streams, filters, target)) < 0 ||
|
||||||
@ -909,9 +909,10 @@ int git_filter_list_stream_file(
|
|||||||
else if (readlen < 0)
|
else if (readlen < 0)
|
||||||
error = readlen;
|
error = readlen;
|
||||||
|
|
||||||
p_close(fd);
|
|
||||||
|
|
||||||
done:
|
done:
|
||||||
|
if (fd >= 0)
|
||||||
|
p_close(fd);
|
||||||
stream_list_free(&filter_streams);
|
stream_list_free(&filter_streams);
|
||||||
git_buf_free(&abspath);
|
git_buf_free(&abspath);
|
||||||
return error;
|
return error;
|
||||||
|
Loading…
Reference in New Issue
Block a user