summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2018-12-05 10:01:14 -0800
committerGitHub <noreply@github.com>2018-12-05 10:01:14 -0800
commit8092c4315b1cf2c817bcb4c549216a647c9d6871 (patch)
tree58863615dccce3fe435649febab5ffd514389bd7
parent788fccc40b28cea2e15bb7a0cafc706bb86d13c1 (diff)
parentf4835e44a7b578d52cc41bb8d9b7ed1b69121f03 (diff)
downloadlibgit2-8092c4315b1cf2c817bcb4c549216a647c9d6871.tar.gz
Merge pull request #4905 from palmin/proxy_stream_close
make proxy_stream_close close target stream even on errors
-rw-r--r--src/filter.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/filter.c b/src/filter.c
index cf8fe7dec..90cc55198 100644
--- a/src/filter.c
+++ b/src/filter.c
@@ -809,6 +809,7 @@ static int proxy_stream_close(git_writestream *s)
{
struct proxy_stream *proxy_stream = (struct proxy_stream *)s;
git_buf *writebuf;
+ git_error_state error_state = {0};
int error;
assert(proxy_stream);
@@ -826,6 +827,11 @@ static int proxy_stream_close(git_writestream *s)
git_buf_sanitize(proxy_stream->output);
writebuf = proxy_stream->output;
} else {
+ /* close stream before erroring out taking care
+ * to preserve the original error */
+ giterr_state_capture(&error_state, error);
+ proxy_stream->target->close(proxy_stream->target);
+ giterr_state_restore(&error_state);
return error;
}