mv_3d: fix coverity issue 88/282088/2
authorsangho park <sangho.g.park@samsung.com>
Tue, 27 Sep 2022 03:42:43 +0000 (12:42 +0900)
committersangho park <sangho.g.park@samsung.com>
Tue, 27 Sep 2022 05:21:40 +0000 (14:21 +0900)
[Version] : 0.23.27-0
[Issue type] : bug fix

fix coverity DefectId 1612133 (resource leak)

Change-Id: I8a8b9a0783db79f3695dc637445dfe62d0b2ea92
Signed-off-by: sangho park <sangho.g.park@samsung.com>
mv_3d/3d/src/mv_3d_open.cpp
packaging/capi-media-vision.spec

index 24d2189..0319351 100644 (file)
@@ -80,6 +80,7 @@ int mv3dConfigure(mv_3d_h mv3d, mv_engine_config_h engine_config)
 {
        LOGI("ENTER");
 
+       Mv3d *pMv3d = NULL;
        if (!mv3d || !engine_config) {
                LOGE("Handle is NULL");
                return MEDIA_VISION_ERROR_INVALID_PARAMETER;
@@ -134,18 +135,6 @@ int mv3dConfigure(mv_3d_h mv3d, mv_engine_config_h engine_config)
                return ret;
        }
 
-       char *stereoConfigFilePath = NULL;
-       ret = mv_engine_config_get_string_attribute(
-                       engine_config, MV_3D_DEPTH_STEREO_CONFIG_FILE_PATH, &stereoConfigFilePath);
-       if (ret != MEDIA_VISION_ERROR_NONE) {
-               LOGE("Failed to get stereo configuration file path");
-               if (stereoConfigFilePath) {
-                       free(stereoConfigFilePath);
-                       stereoConfigFilePath = NULL;
-               }
-               return ret;
-       }
-
        double samplingRatio;
        ret = mv_engine_config_get_double_attribute(
                        engine_config, MV_3D_POINTCLOUD_SAMPLING_RATIO,&samplingRatio);
@@ -170,36 +159,41 @@ int mv3dConfigure(mv_3d_h mv3d, mv_engine_config_h engine_config)
                return ret;
        }
 
+       char *stereoConfigFilePath = NULL;
+       ret = mv_engine_config_get_string_attribute(
+                       engine_config, MV_3D_DEPTH_STEREO_CONFIG_FILE_PATH, &stereoConfigFilePath);
+       if (ret != MEDIA_VISION_ERROR_NONE) {
+               LOGE("Failed to get stereo configuration file path");
+               return ret;
+       }
+
        char *pointcloudOutputFilePath = NULL;
        ret = mv_engine_config_get_string_attribute(
                        engine_config, MV_3D_POINTCLOUD_OUTPUT_FILE_PATH, &pointcloudOutputFilePath);
        if (ret != MEDIA_VISION_ERROR_NONE) {
                LOGE("Failed to get stereo configuration file path");
-               if (pointcloudOutputFilePath) {
-                       free(pointcloudOutputFilePath);
-                       pointcloudOutputFilePath = NULL;
-               }
-               return ret;
+               goto out;
        }
 
-       auto pMv3d = static_cast<Mv3d *>(mv3d);
+       pMv3d = static_cast<Mv3d *>(mv3d);
        ret = pMv3d->Configure(mode, depthWidth, depthHeight, minDisp, maxDisp,
                                                        samplingRatio, outlierRemovalPoints, outlierRemovalRadius,
                                                        stereoConfigFilePath, pointcloudOutputFilePath);
 
-       if (stereoConfigFilePath) {
-               free(stereoConfigFilePath);
-               stereoConfigFilePath = NULL;
+       if (ret != MEDIA_VISION_ERROR_NONE) {
+               LOGE("Failed to configure Depth");
+               goto out;
        }
 
+out:
        if (pointcloudOutputFilePath) {
                free(pointcloudOutputFilePath);
                pointcloudOutputFilePath = NULL;
        }
 
-       if (ret != MEDIA_VISION_ERROR_NONE) {
-               LOGE("Failed to configure Depth");
-               return ret;
+       if (stereoConfigFilePath) {
+               free(stereoConfigFilePath);
+               stereoConfigFilePath = NULL;
        }
 
        LOGI("LEAVE");
index 3e53cfe..fdb9d02 100644 (file)
@@ -1,6 +1,6 @@
 Name:        capi-media-vision
 Summary:     Media Vision library for Tizen Native API
-Version:     0.23.26
+Version:     0.23.27
 Release:     0
 Group:       Multimedia/Framework
 License:     Apache-2.0 and BSD-3-Clause