From 9b5e180a69e29a6266224a6c74868295ff5631a4 Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Tue, 20 Oct 2020 09:21:20 -0700 Subject: [PATCH] Avoid dereferencing a null pointer when the operation is missing. PiperOrigin-RevId: 338073270 Change-Id: I775ef60523186f4394d0e46bbabe5a752d638e34 --- tensorflow/python/eager/pywrap_tfe_src.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tensorflow/python/eager/pywrap_tfe_src.cc b/tensorflow/python/eager/pywrap_tfe_src.cc index 128fb09d114..4bc327adc33 100644 --- a/tensorflow/python/eager/pywrap_tfe_src.cc +++ b/tensorflow/python/eager/pywrap_tfe_src.cc @@ -3606,16 +3606,18 @@ PyObject* TFE_Py_FastPathExecute_C(PyObject* args) { } TFE_Op* op = GetOp(ctx, op_name, op_exec_info.device_name, status); - tensorflow::unwrap(op)->SetStackTrace(tensorflow::GetStackTrace()); auto cleaner = tensorflow::gtl::MakeCleanup([status, ctx, op] { ReturnStatus(status); ReturnOp(ctx, op); }); + if (MaybeRaiseExceptionFromTFStatus(status, nullptr)) { return nullptr; } + tensorflow::unwrap(op)->SetStackTrace(tensorflow::GetStackTrace()); + const tensorflow::OpDef* op_def = tensorflow::unwrap(op)->OpDef(); if (op_def == nullptr) return nullptr;