Skip to content

Commit

Permalink
Merge pull request #49334 from geetachavan1/cherrypicks_QXSXH
Browse files Browse the repository at this point in the history
Fix  and  null pointer dereferences.
  • Loading branch information
mihaimaruseac committed May 20, 2021
2 parents 99b274f + a7033ee commit b24c5f8
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions tensorflow/core/kernels/session_ops.cc
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,11 @@ class GetSessionTensorOp : public OpKernel {
const Tensor& handle = ctx->input(0);
const string& name = handle.scalar<tstring>()();
Tensor val;
OP_REQUIRES_OK(ctx, ctx->session_state()->GetTensor(name, &val));
auto session_state = ctx->session_state();
OP_REQUIRES(ctx, session_state != nullptr,
errors::FailedPrecondition(
"GetSessionTensor called on null session state"));
OP_REQUIRES_OK(ctx, session_state->GetTensor(name, &val));
ctx->set_output(0, val);
}

Expand Down Expand Up @@ -160,7 +164,11 @@ class DeleteSessionTensorOp : public OpKernel {
void Compute(OpKernelContext* ctx) override {
const Tensor& handle = ctx->input(0);
const string& name = handle.scalar<tstring>()();
OP_REQUIRES_OK(ctx, ctx->session_state()->DeleteTensor(name));
auto session_state = ctx->session_state();
OP_REQUIRES(ctx, session_state != nullptr,
errors::FailedPrecondition(
"DeleteSessionTensor called on null session state"));
OP_REQUIRES_OK(ctx, session_state->DeleteTensor(name));
}

TF_DISALLOW_COPY_AND_ASSIGN(DeleteSessionTensorOp);
Expand Down

0 comments on commit b24c5f8

Please sign in to comment.