aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/core/lib/io/zlib_inputstream.cc
diff options
context:
space:
mode:
Diffstat (limited to 'tensorflow/core/lib/io/zlib_inputstream.cc')
-rw-r--r--tensorflow/core/lib/io/zlib_inputstream.cc9
1 files changed, 7 insertions, 2 deletions
diff --git a/tensorflow/core/lib/io/zlib_inputstream.cc b/tensorflow/core/lib/io/zlib_inputstream.cc
index 984fbc2810..bf8dcf0988 100644
--- a/tensorflow/core/lib/io/zlib_inputstream.cc
+++ b/tensorflow/core/lib/io/zlib_inputstream.cc
@@ -25,8 +25,9 @@ ZlibInputStream::ZlibInputStream(
InputStreamInterface* input_stream,
size_t input_buffer_bytes, // size of z_stream.next_in buffer
size_t output_buffer_bytes, // size of z_stream.next_out buffer
- const ZlibCompressionOptions& zlib_options)
- : input_stream_(input_stream),
+ const ZlibCompressionOptions& zlib_options, bool owns_input_stream)
+ : owns_input_stream_(owns_input_stream),
+ input_stream_(input_stream),
input_buffer_capacity_(input_buffer_bytes),
output_buffer_capacity_(output_buffer_bytes),
z_stream_input_(new Bytef[input_buffer_capacity_]),
@@ -41,10 +42,14 @@ ZlibInputStream::~ZlibInputStream() {
if (z_stream_) {
inflateEnd(z_stream_.get());
}
+ if (owns_input_stream_) {
+ delete input_stream_;
+ }
}
Status ZlibInputStream::Reset() {
TF_RETURN_IF_ERROR(input_stream_->Reset());
+ inflateEnd(z_stream_.get());
InitZlibBuffer();
bytes_read_ = 0;
return Status::OK();