mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-15 23:07:54 +00:00
filter: make sure to close the stream even on error
When the stream list init or write fail, we must also make sure to close the stream, as that's the function contract.
This commit is contained in:
parent
678c4aacf5
commit
34ff34fd6a
16
src/filter.c
16
src/filter.c
@ -947,18 +947,20 @@ int git_filter_list_stream_data(
|
|||||||
{
|
{
|
||||||
git_vector filter_streams = GIT_VECTOR_INIT;
|
git_vector filter_streams = GIT_VECTOR_INIT;
|
||||||
git_writestream *stream_start;
|
git_writestream *stream_start;
|
||||||
int error = 0;
|
int error = 0, close_error;
|
||||||
|
|
||||||
git_buf_sanitize(data);
|
git_buf_sanitize(data);
|
||||||
|
|
||||||
if ((error = stream_list_init(
|
if ((error = stream_list_init(&stream_start, &filter_streams, filters, target)) < 0)
|
||||||
&stream_start, &filter_streams, filters, target)) == 0 &&
|
goto out;
|
||||||
(error =
|
|
||||||
stream_start->write(stream_start, data->ptr, data->size)) == 0)
|
|
||||||
error = stream_start->close(stream_start);
|
|
||||||
|
|
||||||
|
error = stream_start->write(stream_start, data->ptr, data->size);
|
||||||
|
|
||||||
|
out:
|
||||||
|
close_error = stream_start->close(stream_start);
|
||||||
stream_list_free(&filter_streams);
|
stream_list_free(&filter_streams);
|
||||||
return error;
|
/* propagate the stream init or write error */
|
||||||
|
return error < 0 ? error : close_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
int git_filter_list_stream_blob(
|
int git_filter_list_stream_blob(
|
||||||
|
Loading…
Reference in New Issue
Block a user