Unverified Commit 3847522e by Edward Thomson Committed by GitHub

Merge pull request #6303 from zawata/legacy_buffer_stream_segfault

filter: Fix Segfault
parents f98dd543 f887fd60
......@@ -893,6 +893,17 @@ static int buffered_stream_write(
return git_str_put(&buffered_stream->input, buffer, len);
}
#ifndef GIT_DEPRECATE_HARD
# define BUF_TO_STRUCT(b, s) \
(b)->ptr = (s)->ptr; \
(b)->size = (s)->size; \
(b)->reserved = (s)->asize;
# define STRUCT_TO_BUF(s, b) \
(s)->ptr = (b)->ptr; \
(s)->size = (b)->size; \
(s)->asize = (b)->reserved;
#endif
static int buffered_stream_close(git_writestream *s)
{
struct buffered_stream *buffered_stream = (struct buffered_stream *)s;
......@@ -902,6 +913,25 @@ static int buffered_stream_close(git_writestream *s)
GIT_ASSERT_ARG(buffered_stream);
#ifndef GIT_DEPRECATE_HARD
if (buffered_stream->write_fn == NULL) {
git_buf legacy_output = GIT_BUF_INIT,
legacy_input = GIT_BUF_INIT;
BUF_TO_STRUCT(&legacy_output, buffered_stream->output);
BUF_TO_STRUCT(&legacy_input, &buffered_stream->input);
error = buffered_stream->legacy_write_fn(
buffered_stream->filter,
buffered_stream->payload,
&legacy_output,
&legacy_input,
buffered_stream->source);
STRUCT_TO_BUF(buffered_stream->output, &legacy_output);
STRUCT_TO_BUF(&buffered_stream->input, &legacy_input);
} else
#endif
error = buffered_stream->write_fn(
buffered_stream->filter,
buffered_stream->payload,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment