aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/core/util/tensor_slice_writer.h
diff options
context:
space:
mode:
authorGravatar Andrew Dai <adai@google.com>2016-01-07 07:46:02 -0800
committerGravatar Vijay Vasudevan <vrv@google.com>2016-01-07 07:46:02 -0800
commit4be49cce22726281a90851d12c99bfdbbeb2739c (patch)
treecc78bd9aadcff02a8e6bbe1ec7e67f0bf82043ea /tensorflow/core/util/tensor_slice_writer.h
parent573fbda10163d4d12871f824acbfd1fb5778332f (diff)
Check the result of serializing a Tensor and return an error if it could not be serialized (most likely because it could not fit into a protobuf). This prevents segfaults when trying to load invalid protobufs.
Change: 111576943
Diffstat (limited to 'tensorflow/core/util/tensor_slice_writer.h')
-rw-r--r--tensorflow/core/util/tensor_slice_writer.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/tensorflow/core/util/tensor_slice_writer.h b/tensorflow/core/util/tensor_slice_writer.h
index 58eeafc17d..3a7d9979f0 100644
--- a/tensorflow/core/util/tensor_slice_writer.h
+++ b/tensorflow/core/util/tensor_slice_writer.h
@@ -136,7 +136,9 @@ Status TensorSliceWriter::Add(const string& name, const TensorShape& shape,
// list the tensor slices we want to save and then another pass to actually
// set the data. Need to figure out if the interface works well.
std::pair<string, string> key_value(key, "");
- sts.AppendToString(&key_value.second);
+ if (!sts.AppendToString(&key_value.second)) {
+ return errors::Internal("Error writing Tensor. Possible size overflow.");
+ }
data_.insert(key_value);
}
++slices_;