diff --git a/onnxruntime/core/providers/tensorrt/tensorrt_provider_factory.cc b/onnxruntime/core/providers/tensorrt/tensorrt_provider_factory.cc index 90aeeb64c9d24..18ec113734b97 100644 --- a/onnxruntime/core/providers/tensorrt/tensorrt_provider_factory.cc +++ b/onnxruntime/core/providers/tensorrt/tensorrt_provider_factory.cc @@ -202,6 +202,20 @@ struct Tensorrt_Provider : Provider { trt_options.trt_tactic_sources = (const char*)dest; } + str_size = internal_options.extra_plugin_lib_paths.size(); + if (str_size == 0) { + trt_options.trt_extra_plugin_lib_paths = nullptr; + } else { + dest = new char[str_size + 1]; +#ifdef _MSC_VER + strncpy_s(dest, str_size + 1, internal_options.extra_plugin_lib_paths.c_str(), str_size); +#else + strncpy(dest, internal_options.extra_plugin_lib_paths.c_str(), str_size); +#endif + dest[str_size] = '\0'; + trt_options.trt_extra_plugin_lib_paths = (const char*)dest; + } + str_size = internal_options.profile_min_shapes.size(); if (str_size == 0) { trt_options.trt_profile_min_shapes = nullptr; diff --git a/onnxruntime/core/session/provider_bridge_ort.cc b/onnxruntime/core/session/provider_bridge_ort.cc index 8f0a5aeaa3975..bf7a3bbd9d380 100644 --- a/onnxruntime/core/session/provider_bridge_ort.cc +++ b/onnxruntime/core/session/provider_bridge_ort.cc @@ -1930,9 +1930,14 @@ ORT_API_STATUS_IMPL(OrtApis::GetTensorRTProviderOptionsByName, ORT_API(void, OrtApis::ReleaseTensorRTProviderOptions, _Frees_ptr_opt_ OrtTensorRTProviderOptionsV2* ptr) { #ifdef USE_TENSORRT if (ptr != nullptr) { - delete ptr->trt_int8_calibration_table_name; - delete ptr->trt_engine_cache_path; - delete ptr->trt_engine_decryption_lib_path; + delete[] ptr->trt_int8_calibration_table_name; + delete[] ptr->trt_engine_cache_path; + delete[] ptr->trt_engine_decryption_lib_path; + delete[] ptr->trt_tactic_sources; + delete[] ptr->trt_extra_plugin_lib_paths; + delete[] ptr->trt_profile_min_shapes; + delete[] ptr->trt_profile_max_shapes; + delete[] ptr->trt_profile_opt_shapes; } std::unique_ptr p(ptr);