Skip to content

Commit a499a0a

Browse files
authored
fix(autoware_tensorrt_classifier): fix bugprone-exception-escape (#9732)
fix: bugprone-error Signed-off-by: kobayu858 <yutaro.kobayashi@tier4.jp>
1 parent f3a258c commit a499a0a

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

perception/autoware_tensorrt_classifier/src/tensorrt_classifier.cpp

+9-3
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,15 @@ TrtClassifier::TrtClassifier(
193193

194194
TrtClassifier::~TrtClassifier()
195195
{
196-
if (m_cuda) {
197-
if (h_img_) CHECK_CUDA_ERROR(cudaFreeHost(h_img_));
198-
if (d_img_) CHECK_CUDA_ERROR(cudaFree(d_img_));
196+
try {
197+
if (m_cuda) {
198+
if (h_img_) CHECK_CUDA_ERROR(cudaFreeHost(h_img_));
199+
if (d_img_) CHECK_CUDA_ERROR(cudaFree(d_img_));
200+
}
201+
} catch (const std::exception & e) {
202+
std::cerr << "Exception in TrtClassifier destructor: " << e.what() << std::endl;
203+
} catch (...) {
204+
std::cerr << "Unknown exception in TrtClassifier destructor" << std::endl;
199205
}
200206
}
201207

0 commit comments

Comments
 (0)