mirror of
https://github.com/boostorg/beast.git
synced 2025-07-29 20:37:31 +02:00
Fix ostream flush:
fix #1853, close #1859, close #1866 After calling the DynamicBuffer commit() function the buffer returned from prepare() can be invalidated but the ostream kept using it.
This commit is contained in:
committed by
Vinnie Falco
parent
fc01de736f
commit
75da7a522e
@ -9,6 +9,7 @@ Version 286:
|
||||
* Fix ostream warning
|
||||
* Field digest is endian-independent
|
||||
* update broken links in README
|
||||
* Fix ostream flush
|
||||
|
||||
API Changes:
|
||||
|
||||
|
@ -100,6 +100,7 @@ public:
|
||||
b_.commit(
|
||||
(this->pptr() - this->pbase()) *
|
||||
sizeof(CharT));
|
||||
this->setp(nullptr, nullptr);
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
@ -169,6 +170,7 @@ public:
|
||||
b_.commit(
|
||||
(this->pptr() - this->pbase()) *
|
||||
sizeof(CharT));
|
||||
this->setp(nullptr, nullptr);
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
@ -66,6 +66,31 @@ public:
|
||||
fail("wrong exception", __FILE__, __LINE__);
|
||||
}
|
||||
}
|
||||
|
||||
// flush
|
||||
{
|
||||
// Issue #1853
|
||||
flat_static_buffer<16> b;
|
||||
auto half_view = string_view(s.data(), 8);
|
||||
{
|
||||
auto os = ostream(b);
|
||||
os << half_view;
|
||||
os.flush();
|
||||
}
|
||||
BEAST_EXPECT(buffers_to_string(b.data()) == half_view);
|
||||
}
|
||||
|
||||
{
|
||||
flat_static_buffer<16> b;
|
||||
{
|
||||
auto os = ostream(b);
|
||||
os << string_view(s.data(), 8);
|
||||
os.flush();
|
||||
os << string_view(s.data() + 8, 8);
|
||||
os.flush();
|
||||
}
|
||||
BEAST_EXPECT(buffers_to_string(b.data()) == s);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
Reference in New Issue
Block a user