Skip to content

Commit 6014129

Browse files
authored
Fix stack buffer overflow in get_view_as_real_copy_out_target_size
Differential Revision: D86356264 Pull Request resolved: #15625
1 parent f41d81a commit 6014129

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

kernels/portable/cpu/op_view_as_real_copy.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ Tensor& view_as_real_copy_out(
4141

4242
// Get the output shape
4343
Tensor::SizesType expected_output_size[kTensorDimensionLimit];
44+
ET_KERNEL_CHECK_MSG(
45+
ctx,
46+
static_cast<size_t>(self.dim()) < kTensorDimensionLimit,
47+
InvalidArgument,
48+
out,
49+
"Output size buffer is too small. Expected at least %zu, got %zu",
50+
self.dim() + 1,
51+
kTensorDimensionLimit);
4452
get_view_as_real_copy_out_target_size(self, expected_output_size);
4553

4654
// Resize for dynamic shape

0 commit comments

Comments
 (0)