From bcc19995745528c84fd880fe5c6262834e92ba23 Mon Sep 17 00:00:00 2001 From: Lizan Zhou Date: Wed, 17 May 2017 22:04:11 -0700 Subject: [PATCH] test: fix FakeStream::encodeData to copy data before posting --- test/integration/fake_upstream.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/integration/fake_upstream.cc b/test/integration/fake_upstream.cc index 265eccaab95f5..9ee1b2596c1b1 100644 --- a/test/integration/fake_upstream.cc +++ b/test/integration/fake_upstream.cc @@ -64,8 +64,9 @@ void FakeStream::encodeData(uint64_t size, bool end_stream) { } void FakeStream::encodeData(Buffer::Instance& data, bool end_stream) { - parent_.connection().dispatcher().post([this, &data, end_stream]() - -> void { encoder_.encodeData(data, end_stream); }); + std::shared_ptr data_copy(new Buffer::OwnedImpl(data)); + parent_.connection().dispatcher().post( + [this, data_copy, end_stream]() -> void { encoder_.encodeData(*data_copy, end_stream); }); } void FakeStream::encodeTrailers(const Http::HeaderMapImpl& trailers) {