!46519 [MS][InplaceOp] Add memory out-of-bounds check for indices

Merge pull request !46519 from 陈宇/dev_inplace_coredump
This commit is contained in:
i-robot 2022-12-08 11:42:53 +00:00 committed by Gitee
commit 90e474c354
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
1 changed files with 4 additions and 0 deletions

View File

@ -128,6 +128,10 @@ class InplaceOpCpuTypeFunc : public CpuKernelFunc {
int Resize(const BaseOperatorPtr &, const std::vector<KernelTensorPtr> &inputs, const std::vector<KernelTensorPtr> &,
const std::map<uint32_t, tensor::TensorPtr> &) override {
auto v_shape = inputs.at(kIndex1)->GetShapeVector();
if (v_shape.at(0) != SizeToLong(indices_.size())) {
MS_LOG(ERROR) << "For 'InplaceOp', the size of indices must equal to input_v's shape[0].";
return KRET_RESIZE_FAILED;
}
// x_shape_.size() == v_shape.size() is checked at front end
// x_shape_[1:] == v_shape[1:] is checked at front end