diff options
author | Anders Borum <anders@algoritmer.dk> | 2018-12-04 21:48:12 +0100 |
---|---|---|
committer | Edward Thomson <ethomson@edwardthomson.com> | 2019-01-18 23:01:37 +0000 |
commit | c3b2053d964bea36b5a9440321b5d02ae13e3421 (patch) | |
tree | d061dd3c90cde045f48f07d924249a06b960afca | |
parent | 8ce7272d40975e90581f5f76ab743ac0ec4164ad (diff) | |
download | libgit2-c3b2053d964bea36b5a9440321b5d02ae13e3421.tar.gz |
make proxy_stream_close close target stream even on errors
When git_filter_apply_fn callback returns a error while smudging proxy_stream_close
ends up returning without closing the stream. This is turn makes blob_content_to_file
crash as it asserts the stream being closed whether there are errors or not.
Closing the target stream on error fixes this problem.
-rw-r--r-- | src/filter.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/filter.c b/src/filter.c index 6ab09790b..ad741d6af 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; } |