Skip to content

Commit

Permalink
Fix nullptr deref and heap OOB access in binary cwise ops.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 387936777
Change-Id: I608b8074cec36a982cca622b7144cb2c43e6e19f
  • Loading branch information
mihaimaruseac authored and tensorflower-gardener committed Jul 31, 2021
1 parent bc9c546 commit 93f428f
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tensorflow/core/kernels/cwise_ops_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,11 @@ class SimpleBinaryOp : public OpKernel {
void Compute(OpKernelContext* ctx) override {
const Tensor& in0 = ctx->input(0);
const Tensor& in1 = ctx->input(1);
OP_REQUIRES(
ctx, in0.NumElements() == in1.NumElements(),
errors::InvalidArgument("The two arguments to a cwise op must have "
"same number of elements, got ",
in0.NumElements(), " and ", in1.NumElements()));
auto in0_flat = in0.flat<Tin>();
auto in1_flat = in1.flat<Tin>();
const Device& eigen_device = ctx->eigen_device<Device>();
Expand Down

0 comments on commit 93f428f

Please sign in to comment.