Bug fix: Don't dereference nullptr in OpKernelContext::input_alloc_attr().
authorA. Unique TensorFlower <gardener@tensorflow.org>
Mon, 5 Feb 2018 20:16:04 +0000 (12:16 -0800)
committerTensorFlower Gardener <gardener@tensorflow.org>
Mon, 5 Feb 2018 20:23:35 +0000 (12:23 -0800)
PiperOrigin-RevId: 184566770

tensorflow/core/framework/op_kernel.h

index a3dc96b..c45026c 100644 (file)
@@ -909,9 +909,13 @@ class OpKernelContext {
   }
 
   AllocatorAttributes input_alloc_attr(int index) const {
-    DCHECK_GE(index, 0);
-    DCHECK_LT(index, params_->input_alloc_attrs->size());
-    return (*params_->input_alloc_attrs)[index];
+    if (params_->input_alloc_attrs == nullptr) {
+      return AllocatorAttributes();
+    } else {
+      DCHECK_GE(index, 0);
+      DCHECK_LT(index, params_->input_alloc_attrs->size());
+      return (*params_->input_alloc_attrs)[index];
+    }
   }
 
   AllocatorAttributes output_alloc_attr(int index) const {