Skip to content

Commit a2b743f

Browse files
Fix heap OOB in tf.raw_ops.RaggedGather
PiperOrigin-RevId: 388355464 Change-Id: If14d96231d1cd7aad7c4d1c22c1bab1576b75717
1 parent 4979e3b commit a2b743f

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

tensorflow/core/kernels/ragged_gather_op.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,21 @@ class RaggedGatherOpBase : public OpKernel {
5858

5959
void Compute(OpKernelContext* context) override {
6060
// Get the input Tensors.
61+
6162
OpInputList params_nested_splits_in;
6263
OP_REQUIRES_OK(context, context->input_list("params_nested_splits",
6364
&params_nested_splits_in));
65+
OP_REQUIRES(
66+
context, params_nested_splits_in.size() > 0,
67+
errors::InvalidArgument("params_nested_splits must be non empty"));
68+
6469
const Tensor& params_dense_values_in =
6570
context->input(params_nested_splits_in.size());
6671
const Tensor& indices_in =
6772
context->input(params_nested_splits_in.size() + 1);
6873

69-
DCHECK_GT(params_nested_splits_in.size(), 0); // Enforced by REGISTER_OP.
74+
OP_REQUIRES(context, params_nested_splits_in[0].dims() > 0,
75+
errors::InvalidArgument("Split tensors must not be scalars"));
7076
SPLITS_TYPE num_params = params_nested_splits_in[0].dim_size(0) - 1;
7177
OP_REQUIRES_OK(context, ValidateIndices(indices_in, num_params));
7278

0 commit comments

Comments
 (0)