!43382 [MSLITE][CPU] fuzz problem fix

Merge pull request !43382 from Greatpan/conv_fuzz_fix
This commit is contained in:
i-robot 2022-10-09 03:49:19 +00:00 committed by Gitee
commit 6b67c22e32
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 7 additions and 4 deletions

View File

@ -233,7 +233,7 @@ bool ConvolutionDelegateCPUKernel::CheckAvxUseSWConv(const ConvParameter *conv_p
kernel::LiteKernel *ConvolutionDelegateCPUKernel::CreateConv1x1MatmulKernel() {
auto conv_param = reinterpret_cast<ConvParameter *>(op_parameter_);
matmul_param_ = new (std::nothrow) MatMulParameter;
matmul_param_ = reinterpret_cast<MatMulParameter *>(malloc(sizeof(MatMulParameter)));
if (matmul_param_ == nullptr) {
MS_LOG(WARNING) << "Memory allocation failed, Create Conv1x1 Matmul Kernel failed.";
return nullptr;

View File

@ -31,14 +31,17 @@ class ConvolutionDelegateCPUKernel : public LiteKernel {
: LiteKernel(parameter, inputs, outputs, ctx) {}
~ConvolutionDelegateCPUKernel() override {
FreeCopiedData();
if (matmul_param_ != nullptr) {
matmul_param_ = nullptr;
}
if (conv_kernel_ != nullptr) {
if (matmul_param_ != nullptr) {
free(op_parameter_);
}
op_parameter_ = nullptr; // op_parameter will be freed in conv_kernel
delete conv_kernel_;
conv_kernel_ = nullptr;
}
if (matmul_param_ != nullptr) {
matmul_param_ = nullptr;
}
};
int Prepare() override;
int ReSize() override;