From 97e4f0d3945c8482bb8c6569bcccc4be22a7f573 Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Wed, 15 Apr 2020 13:04:37 -0700 Subject: [PATCH] LSC: Allow targets to pass with `-fsanitize=null` under `--config=asan`. This is a manually-generated change. Ensure that behavior and style are preserved by carefully inspecting the diff. This CL fixes one of the many targets in TAP that test with ASan but fail with `-fsanitize=null`. We would like to enable the Null Pointer Sanitizer in builds that use Address Sanitizer globally, and this change gets us one step closer to that goal. PiperOrigin-RevId: 306704264 Change-Id: I15fc65a7e3c7b3ed81e5b72038b070c6b847ff3f --- tensorflow/core/framework/function.cc | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tensorflow/core/framework/function.cc b/tensorflow/core/framework/function.cc index cd00fa4f449..22fc27771f0 100644 --- a/tensorflow/core/framework/function.cc +++ b/tensorflow/core/framework/function.cc @@ -1505,9 +1505,17 @@ const FunctionDef* FunctionLibraryDefinition::GetAttrImpl( // function's attrs to see if noinline is specified. Otherwise, // uses func's attrs. if (!grad_name.empty()) { - return &(FindHelper(grad_name)->fdef); + if (const auto helper = FindHelper(grad_name)) { + return &(helper->fdef); + } else { + return nullptr; + } + } + if (const auto helper = FindHelper(func_name)) { + return &(helper->fdef); + } else { + return nullptr; } - return &(FindHelper(func_name)->fdef); } }