diff --git a/mindspore/lite/tools/optimizer/fusion/constant_folding_fusion.cc b/mindspore/lite/tools/optimizer/fusion/constant_folding_fusion.cc index 2ca1d8d4c6fb308d4a8af46710269c98534ad4a4..992e91dd1fab4a707626c9cfe31b136136c9f342 100644 --- a/mindspore/lite/tools/optimizer/fusion/constant_folding_fusion.cc +++ b/mindspore/lite/tools/optimizer/fusion/constant_folding_fusion.cc @@ -52,7 +52,7 @@ std::vector GetCNodeInputTensors(const CNodePtr &CNode) { delete lite_tensor; return input_tensors; } - auto tensor_data = reinterpret_cast(malloc(lite_tensor_size / sizeof(char))); + auto tensor_data = new (std::nothrow) uint8_t[lite_tensor_size / sizeof(char)]; if (tensor_data == nullptr) { MS_LOG(ERROR) << "tensor_data is nullptr"; delete lite_tensor; @@ -92,7 +92,7 @@ ParameterPtr CreateNewParamter(const FuncGraphPtr &func_graph, Tensor *tensor) { } auto ret = memcpy_s(tensor_data, size * sizeof(float), tensor->Data(), size * sizeof(float)); if (ret != EOK) { - delete tensor_data; + delete[] tensor_data; MS_LOG(ERROR) << "memcpy error: " << ret; return nullptr; }