Skip to content

Commit 8092c43

Browse files
authored
Merge pull request libgit2#4905 from palmin/proxy_stream_close
make proxy_stream_close close target stream even on errors
2 parents 788fccc + f4835e4 commit 8092c43

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/filter.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -809,6 +809,7 @@ static int proxy_stream_close(git_writestream *s)
809809
{
810810
struct proxy_stream *proxy_stream = (struct proxy_stream *)s;
811811
git_buf *writebuf;
812+
git_error_state error_state = {0};
812813
int error;
813814

814815
assert(proxy_stream);
@@ -826,6 +827,11 @@ static int proxy_stream_close(git_writestream *s)
826827
git_buf_sanitize(proxy_stream->output);
827828
writebuf = proxy_stream->output;
828829
} else {
830+
/* close stream before erroring out taking care
831+
* to preserve the original error */
832+
giterr_state_capture(&error_state, error);
833+
proxy_stream->target->close(proxy_stream->target);
834+
giterr_state_restore(&error_state);
829835
return error;
830836
}
831837

0 commit comments

Comments
 (0)