commit | 02b51259f0d54ddde325b1d3ef5ed7ec3251c9b6 | [log] [tgz] |
---|---|---|
author | Junxiao Shi <git@mail1.yoursunny.com> | Sun Sep 04 04:30:31 2016 +0000 |
committer | Junxiao Shi <git@mail1.yoursunny.com> | Sun Sep 04 04:30:31 2016 +0000 |
tree | 7182642266e433145fe99830512b40035b0c3521 | |
parent | a88c9c7716afaea6d4b5adbb9cc50e99f52c3142 [diff] |
encoding: OBufferStream closes stream in destructor This avoids use-after-free error from base class destructor. refs #3727 Change-Id: Ie9abde981fe98dcb1bc541858ed03afbaae56ad1
diff --git a/src/encoding/buffer-stream.cpp b/src/encoding/buffer-stream.cpp index e60ba77..3fed843 100644 --- a/src/encoding/buffer-stream.cpp +++ b/src/encoding/buffer-stream.cpp
@@ -45,6 +45,11 @@ open(m_device); } +OBufferStream::~OBufferStream() +{ + close(); +} + shared_ptr<Buffer> OBufferStream::buf() {
diff --git a/src/encoding/buffer-stream.hpp b/src/encoding/buffer-stream.hpp index b813e49..e7dc60f 100644 --- a/src/encoding/buffer-stream.hpp +++ b/src/encoding/buffer-stream.hpp
@@ -72,6 +72,8 @@ public: OBufferStream(); + ~OBufferStream(); + /** * Flush written data to the stream and return shared pointer to the underlying buffer */