null pointer dereference on GetInput
Hi @SiriusHsh 

As this [comment](https://github.com/tensorflow/tensorflow/issues/60620#issuecomment-1553442519) suggests, please consult https://github.com/tensorflow/tensorflow/blob/master/SECURITY.md#vulnerabilities-in-tensorflow and follow rules for responsible disclosure.

Thanks.
<details><summary>Click to expand!</summary> 
 
 ### Issue Type

Bug

### Have you reproduced the bug with TF nightly?

No

### Source

source

### Tensorflow Version

tf 2.14.0

### Custom Code

Yes

### OS Platform and Distribution

Ubuntu 18.04.6

### Mobile device

_No response_

### Python version

Python 3.8.3

### Bazel version

bazel 5.3.0

### GCC/Compiler version

gcc 7.5.0

### CUDA/cuDNN version

_No response_

### GPU model and memory

_No response_

### Current Behaviour?

The `GetInput` function may return a null pointer, similarly, the `GetOutput` function may also return a null pointer.

```c
// kernel_util.cc
const TfLiteTensor* GetInput(const TfLiteContext* context,
                             const TfLiteNode* node, int index) {
  return GetMutableInput(context, node, index);
}


inline TfLiteTensor* GetMutableInput(const TfLiteContext* context,
                                     const TfLiteNode* node, int index) {
  const int tensor_index = ValidateTensorIndexing(
      context, index, node->inputs->size, node->inputs->data);
  if (tensor_index < 0) {
    return nullptr;   // here
  }
  return GetTensorAtIndex(context, tensor_index);
}
```



Subsequent operations may cause null pointer dereferencing.

```c
// pad.cc
struct PadContext {
  PadContext(TfLiteContext* context, TfLiteNode* node) {
    input = GetInput(context, node, 0);  // null pointer
    paddings = GetInput(context, node, 1);
    if (NumInputs(node) == 3) {
      constant_values = GetOptionalInputTensor(context, node, 2);
    } else {
      constant_values = nullptr;
    }
    output = GetOutput(context, node, 0);
    dims = NumDimensions(input);    // null dereference
    ...
 }
        
 inline int NumDimensions(const TfLiteTensor* t) { return t->dims->size; }   
```



Similar use cases are also common. The axis of op_context may be null, leading to null pointer dereferencing when accessing op_context.axis->type.

```c
//reduce.cc
TfLiteStatus PrepareSimple(TfLiteContext* context, TfLiteNode* node) {
  TF_LITE_ENSURE_EQ(context, NumInputs(node), 2);
  TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1);

  OpContext op_context(context, node);
  TF_LITE_ENSURE_TYPES_EQ(context, op_context.axis->type, kTfLiteInt32);  // op_context.axis->type
   ...


struct OpContext {
  OpContext(TfLiteContext* context, TfLiteNode* node) {
    params = reinterpret_cast<TfLiteReducerParams*>(node->builtin_data);
    input = GetInput(context, node, 0);
    axis = GetInput(context, node, 1);  // axis may be null
	...
```
[getinput_getoutput_nullptr.zip](https://github.com/tensorflow/tensorflow/files/11503582/getinput_getoutput_nullptr.zip)


### Standalone code to reproduce the issue

```shell
When I use the benchmark tool for PoC validation, it causes the TensorFlow Lite inference process to be subjected to a DOS（coredump).


❯ ./benchmark_model --graph=getinput_getoutput_nullptr.tflite
INFO: STARTING!
INFO: Log parameter values verbosely: [0]
INFO: Graph: [getinput_getoutput_nullptr.tflite]
INFO: Loaded model getinput_getoutput_nullptr.tflite
INFO: Created TensorFlow Lite XNNPACK delegate for CPU.
[1]    29697 segmentation fault (core dumped)  ./benchmark_model --graph=getinput_getoutput_nullptr.tflite
```
```


### Relevant log output

_No response_</details>