Validate null pointer dereference
Let's try with this fix, but if test fail let's do the real larger change that handles this better (https://github.com/tensorflow/tensorflow/pull/60296#discussion_r1163413390)
Added validation to check if the null pointer is dereferenced before executing the code.
Fixes: https://github.com/tensorflow/tensorflow/issues/60220