inference: fix coverity issue 77/317477/2
authorInki Dae <inki.dae@samsung.com>
Wed, 11 Sep 2024 01:16:11 +0000 (10:16 +0900)
committerInki Dae <inki.dae@samsung.com>
Wed, 11 Sep 2024 03:58:46 +0000 (12:58 +0900)
Fix coverity issue - CID 1790310/314/317/329/335 - Uncaught exception.

Change-Id: I91779a6047edaed9005621c00b4a21ae7ca6a965
Signed-off-by: Inki Dae <inki.dae@samsung.com>
inference/backends/mediavision/src/MvFaceDetection.cpp
inference/backends/mediavision/src/MvFaceLandmark.cpp
inference/backends/mediavision/src/MvFaceRecognition.cpp
inference/backends/mediavision/src/MvImageClassification.cpp
inference/backends/mediavision/src/MvObjectDetection.cpp

index dfec6ebe76fa5c8766c7e036e84907963362c416..75dd7b6cfc0db353e0f1ec47f77cf1771fffadf7 100644 (file)
@@ -35,7 +35,14 @@ MvFaceDetection::MvFaceDetection()
 
 MvFaceDetection::~MvFaceDetection()
 {
-       mv_face_detection_destroy(_handle);
+       try {
+               int ret = mv_face_detection_destroy(_handle);
+               if (ret != MEDIA_VISION_ERROR_NONE)
+                       SINGLEO_LOGE("Fail to destroy face detection handle.(%d)", ret);
+       } catch (const runtime_error &e) {
+               SINGLEO_LOGE("Failed to destroy face detection handle: %s", e.what());
+               throw runtime_error("Failed to destroy face detection handle.");
+       }
 }
 
 void MvFaceDetection::configure()
index 5abf0fdcdfec18153680e3ba9932aa1a3b0b735a..90906d59af8e9eb8e5d60c15e2e1b4d807770acb 100644 (file)
@@ -35,7 +35,14 @@ MvFaceLandmark::MvFaceLandmark()
 
 MvFaceLandmark::~MvFaceLandmark()
 {
-       mv_facial_landmark_destroy(_handle);
+       try {
+               int ret = mv_facial_landmark_destroy(_handle);
+               if (ret != MEDIA_VISION_ERROR_NONE)
+                       SINGLEO_LOGE("Fail to destroy facial landmark handle.(%d)", ret);
+       } catch (const std::runtime_error &e) {
+               SINGLEO_LOGE("Failed to destroy facial landmark handle: %s", e.what());
+               throw runtime_error("Failed to destroy facial landmark handle.");
+       }
 }
 
 void MvFaceLandmark::configure()
index 87f37e7fe5ae2d13637ede649c1452231cfd772b..d5d1e46662675e52ded24b8ab7e4ff696c6da669 100644 (file)
@@ -35,7 +35,14 @@ MvFaceRecognition::MvFaceRecognition()
 
 MvFaceRecognition::~MvFaceRecognition()
 {
-       mv_face_recognition_destroy(_handle);
+       try {
+               int ret = mv_face_recognition_destroy(_handle);
+               if (ret != MEDIA_VISION_ERROR_NONE)
+                       SINGLEO_LOGE("Fail to destroy face recognition handle.(%d)", ret);
+       } catch (const std::runtime_error &e) {
+               SINGLEO_LOGE("Failed to destroy face recognition handle: %s", e.what());
+               throw runtime_error("Failed to destroy face recognition handle.");
+       }
 }
 
 void MvFaceRecognition::configure()
index 250964b26d2972c96f737fe97569340b0f2845bd..a8657a4fe3740d4d0e98b904240819921798d0c6 100644 (file)
@@ -35,7 +35,14 @@ MvImageClassification::MvImageClassification()
 
 MvImageClassification::~MvImageClassification()
 {
-       mv_image_classification_destroy(_handle);
+       try {
+               int ret = mv_image_classification_destroy(_handle);
+               if (ret != MEDIA_VISION_ERROR_NONE)
+                       SINGLEO_LOGE("Fail to destroy image classification handle.(%d)", ret);
+       } catch (const std::runtime_error &e) {
+               SINGLEO_LOGE("Failed to destroy image classification handle: %s", e.what());
+               throw runtime_error("Failed to destroy image classification handle.");
+       }
 }
 
 void MvImageClassification::configure()
index ef81bb51ee37ee8e4f0d69778039e937995f9998..88fb8b89dfbc9af712382f2fdbee83f304559086 100644 (file)
@@ -35,7 +35,14 @@ MvObjectDetection::MvObjectDetection()
 
 MvObjectDetection::~MvObjectDetection()
 {
-       mv_object_detection_destroy(_handle);
+       try {
+               int ret = mv_object_detection_destroy(_handle);
+               if (ret != MEDIA_VISION_ERROR_NONE)
+                       SINGLEO_LOGE("Fail to destroy object detection handle.(%d)", ret);
+       } catch (const std::runtime_error &e) {
+               SINGLEO_LOGE("Failed to destroy object detection handle: %s", e.what());
+               throw runtime_error("Failed to destroy object detection handle.");
+       }
 }
 
 void MvObjectDetection::configure()