-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
-
Server Programmability
-
Fully Compatible
-
ALL
-
Programmability 2024-10-28, Programmability 2024-11-11
This constructor exposes a pointer to the streambuf data member _buf before that data member has been initialized. This is incorrect.
ostream supports a 2-phase initialization for cases like this where the streambuf isn't ready yet at the time of construction. You initialize the std::ostream with no arguments and call ostream::init(std::streambuf*) afterwards.
Broken:
MallocFreeOStream() : std::ostream(&_buf) {}
Fixed:
MallocFreeOStream() { init(&_buf); }