Skip to content

Commit 93f428f

Browse files
Fix nullptr deref and heap OOB access in binary cwise ops.
PiperOrigin-RevId: 387936777 Change-Id: I608b8074cec36a982cca622b7144cb2c43e6e19f
1 parent bc9c546 commit 93f428f

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Diff for: tensorflow/core/kernels/cwise_ops_common.h

+5
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,11 @@ class SimpleBinaryOp : public OpKernel {
265265
void Compute(OpKernelContext* ctx) override {
266266
const Tensor& in0 = ctx->input(0);
267267
const Tensor& in1 = ctx->input(1);
268+
OP_REQUIRES(
269+
ctx, in0.NumElements() == in1.NumElements(),
270+
errors::InvalidArgument("The two arguments to a cwise op must have "
271+
"same number of elements, got ",
272+
in0.NumElements(), " and ", in1.NumElements()));
268273
auto in0_flat = in0.flat<Tin>();
269274
auto in1_flat = in1.flat<Tin>();
270275
const Device& eigen_device = ctx->eigen_device<Device>();

0 commit comments

Comments
 (0)