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()
 {