aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/core/kernels/dynamic_stitch_op.cc
diff options
context:
space:
mode:
authorGravatar Allen Lavoie <allenl@google.com>2018-09-07 09:46:42 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-09-07 09:54:04 -0700
commitcd46846e251374ca11a4f082e5128c324ce51b46 (patch)
tree3f46042a1d9bef1b58a7363e06002412dc081eab /tensorflow/core/kernels/dynamic_stitch_op.cc
parent90d729c31c0569e017f49d95e2f218ce709ca808 (diff)
Remove some undefined behavior in DynamicStitchOp
Zero-sized tensors ended up dereferencing and immediately taking the address of a null pointer, then not using the result. Removes the dereference to appease ubsan. (Previously the indexing was &element(0, 0), which regardless of row/column major should map to index 0) PiperOrigin-RevId: 211989827
Diffstat (limited to 'tensorflow/core/kernels/dynamic_stitch_op.cc')
-rw-r--r--tensorflow/core/kernels/dynamic_stitch_op.cc4
1 files changed, 2 insertions, 2 deletions
diff --git a/tensorflow/core/kernels/dynamic_stitch_op.cc b/tensorflow/core/kernels/dynamic_stitch_op.cc
index b01db91720..fb2a4cc8ef 100644
--- a/tensorflow/core/kernels/dynamic_stitch_op.cc
+++ b/tensorflow/core/kernels/dynamic_stitch_op.cc
@@ -247,8 +247,8 @@ class DynamicStitchOpImplCPU : public DynamicStitchOpImplBase<T> {
data.shaped<T, 2>({indices_vec.dimension(0), slice_size});
if (DataTypeCanUseMemcpy(DataTypeToEnum<T>::v())) {
- T* merged_base = &merged_flat(0, 0);
- const T* data_base = &data_flat(0, 0);
+ T* merged_base = merged_flat.data();
+ const T* data_base = data_flat.data();
for (int i = 0; i < indices_vec.size(); i++) {
int32 index = internal::SubtleMustCopy(indices_vec(i));
OP_REQUIRES(