Fix resource leak issues and svace issues 32/215132/5
authorTae-Young Chung <ty83.chung@samsung.com>
Wed, 2 Oct 2019 02:13:12 +0000 (11:13 +0900)
committerTae-Young Chung <ty83.chung@samsung.com>
Wed, 2 Oct 2019 05:10:00 +0000 (14:10 +0900)
CID 1087571, 1087654, 1087562, 1087542, 1087540

Change-Id: Ia054980b6d7e76bef5895f48e1c89f6d3d1ef975
Signed-off-by: Tae-Young Chung <ty83.chung@samsung.com>
13 files changed:
mv_barcode/barcode_detector/src/mv_private.c
mv_barcode/barcode_generator/src/mv_private.c
mv_common/src/mv_common_c.cpp
mv_common/src/mv_private.c
mv_face/face/src/FaceTrackingModel.cpp
mv_face/face/src/mv_private.c
mv_image/image/src/mv_private.c
mv_inference/inference/src/mv_private.c
mv_surveillance/surveillance/src/mv_private.c
packaging/capi-media-vision.spec
src/mv_private.c
test/testsuites/image/image_test_suite.c
test/testsuites/inference/inference_test_suite.c

index 68cbb6b..16ae6a4 100644 (file)
@@ -66,7 +66,7 @@ bool __mv_check_system_info_feature_supported()
                                        "http://tizen.org/feature/vision.inference.image",
                                        &isInferenceImageSupported);
 
-       if (nRetVal4 != SYSTEM_INFO_ERROR_NONE) {
+       if (nRetVal5 != SYSTEM_INFO_ERROR_NONE) {
                LOGE("SYSTEM_INFO_ERROR: vision.inference.image");
                return false;
        }
@@ -75,7 +75,7 @@ bool __mv_check_system_info_feature_supported()
                                        "http://tizen.org/feature/vision.inference.face",
                                        &isInferenceFaceSupported);
 
-       if (nRetVal4 != SYSTEM_INFO_ERROR_NONE) {
+       if (nRetVal6 != SYSTEM_INFO_ERROR_NONE) {
                LOGE("SYSTEM_INFO_ERROR: vision.inference.face");
                return false;
        }
index 68cbb6b..16ae6a4 100644 (file)
@@ -66,7 +66,7 @@ bool __mv_check_system_info_feature_supported()
                                        "http://tizen.org/feature/vision.inference.image",
                                        &isInferenceImageSupported);
 
-       if (nRetVal4 != SYSTEM_INFO_ERROR_NONE) {
+       if (nRetVal5 != SYSTEM_INFO_ERROR_NONE) {
                LOGE("SYSTEM_INFO_ERROR: vision.inference.image");
                return false;
        }
@@ -75,7 +75,7 @@ bool __mv_check_system_info_feature_supported()
                                        "http://tizen.org/feature/vision.inference.face",
                                        &isInferenceFaceSupported);
 
-       if (nRetVal4 != SYSTEM_INFO_ERROR_NONE) {
+       if (nRetVal6 != SYSTEM_INFO_ERROR_NONE) {
                LOGE("SYSTEM_INFO_ERROR: vision.inference.face");
                return false;
        }
index fa4b6f8..28ba838 100644 (file)
@@ -594,7 +594,15 @@ int mv_engine_config_get_string_attribute_c(
                return MEDIA_VISION_ERROR_OUT_OF_MEMORY;
        }
 
-       if (attributeValue.copy(*value, stringSize) != attributeValue.size()) {
+       try {
+               size_t copiedSize = attributeValue.copy(*value, stringSize);
+               if (copiedSize != attributeValue.size()) {
+                       LOGE("Conversion from string to char* failed");
+                       free(*value);
+                       (*value) = NULL;
+                       return MEDIA_VISION_ERROR_INVALID_OPERATION;
+               }
+       } catch (std::out_of_range& e) {
                LOGE("Conversion from string to char* failed");
                free(*value);
                (*value) = NULL;
index 68cbb6b..16ae6a4 100644 (file)
@@ -66,7 +66,7 @@ bool __mv_check_system_info_feature_supported()
                                        "http://tizen.org/feature/vision.inference.image",
                                        &isInferenceImageSupported);
 
-       if (nRetVal4 != SYSTEM_INFO_ERROR_NONE) {
+       if (nRetVal5 != SYSTEM_INFO_ERROR_NONE) {
                LOGE("SYSTEM_INFO_ERROR: vision.inference.image");
                return false;
        }
@@ -75,7 +75,7 @@ bool __mv_check_system_info_feature_supported()
                                        "http://tizen.org/feature/vision.inference.face",
                                        &isInferenceFaceSupported);
 
-       if (nRetVal4 != SYSTEM_INFO_ERROR_NONE) {
+       if (nRetVal6 != SYSTEM_INFO_ERROR_NONE) {
                LOGE("SYSTEM_INFO_ERROR: vision.inference.face");
                return false;
        }
index 46faa0b..83f7ff6 100644 (file)
@@ -73,13 +73,17 @@ int FaceTrackingModel::save(const std::string& fileName)
 
        filePath = fileName;
 
-       std::string prefixPath = filePath.substr(0, filePath.find_last_of('/'));
-       LOGD("prefixPath: %s", prefixPath.c_str());
-
-       /* check the directory is available */
-       if (access(prefixPath.c_str(), F_OK)) {
-               LOGE("Can't save tracking model. Path[%s] doesn't existed.", prefixPath.c_str());
-
+       try {
+               std::string prefixPath = filePath.substr(0, filePath.find_last_of('/'));
+               LOGD("prefixPath: %s", prefixPath.c_str());
+               /* check the directory is available */
+               if (access(prefixPath.c_str(), F_OK)) {
+                       LOGE("Can't save tracking model. Path[%s] doesn't existed.", prefixPath.c_str());
+
+                       return MEDIA_VISION_ERROR_INVALID_PATH;
+               }
+       } catch (std::out_of_range& e) {
+               LOGE("Can't save tracking model. Path[%s] is invalid.", filePath.c_str());
                return MEDIA_VISION_ERROR_INVALID_PATH;
        }
 
index 68cbb6b..16ae6a4 100644 (file)
@@ -66,7 +66,7 @@ bool __mv_check_system_info_feature_supported()
                                        "http://tizen.org/feature/vision.inference.image",
                                        &isInferenceImageSupported);
 
-       if (nRetVal4 != SYSTEM_INFO_ERROR_NONE) {
+       if (nRetVal5 != SYSTEM_INFO_ERROR_NONE) {
                LOGE("SYSTEM_INFO_ERROR: vision.inference.image");
                return false;
        }
@@ -75,7 +75,7 @@ bool __mv_check_system_info_feature_supported()
                                        "http://tizen.org/feature/vision.inference.face",
                                        &isInferenceFaceSupported);
 
-       if (nRetVal4 != SYSTEM_INFO_ERROR_NONE) {
+       if (nRetVal6 != SYSTEM_INFO_ERROR_NONE) {
                LOGE("SYSTEM_INFO_ERROR: vision.inference.face");
                return false;
        }
index 68cbb6b..16ae6a4 100644 (file)
@@ -66,7 +66,7 @@ bool __mv_check_system_info_feature_supported()
                                        "http://tizen.org/feature/vision.inference.image",
                                        &isInferenceImageSupported);
 
-       if (nRetVal4 != SYSTEM_INFO_ERROR_NONE) {
+       if (nRetVal5 != SYSTEM_INFO_ERROR_NONE) {
                LOGE("SYSTEM_INFO_ERROR: vision.inference.image");
                return false;
        }
@@ -75,7 +75,7 @@ bool __mv_check_system_info_feature_supported()
                                        "http://tizen.org/feature/vision.inference.face",
                                        &isInferenceFaceSupported);
 
-       if (nRetVal4 != SYSTEM_INFO_ERROR_NONE) {
+       if (nRetVal6 != SYSTEM_INFO_ERROR_NONE) {
                LOGE("SYSTEM_INFO_ERROR: vision.inference.face");
                return false;
        }
index 68cbb6b..16ae6a4 100644 (file)
@@ -66,7 +66,7 @@ bool __mv_check_system_info_feature_supported()
                                        "http://tizen.org/feature/vision.inference.image",
                                        &isInferenceImageSupported);
 
-       if (nRetVal4 != SYSTEM_INFO_ERROR_NONE) {
+       if (nRetVal5 != SYSTEM_INFO_ERROR_NONE) {
                LOGE("SYSTEM_INFO_ERROR: vision.inference.image");
                return false;
        }
@@ -75,7 +75,7 @@ bool __mv_check_system_info_feature_supported()
                                        "http://tizen.org/feature/vision.inference.face",
                                        &isInferenceFaceSupported);
 
-       if (nRetVal4 != SYSTEM_INFO_ERROR_NONE) {
+       if (nRetVal6 != SYSTEM_INFO_ERROR_NONE) {
                LOGE("SYSTEM_INFO_ERROR: vision.inference.face");
                return false;
        }
index 68cbb6b..16ae6a4 100644 (file)
@@ -66,7 +66,7 @@ bool __mv_check_system_info_feature_supported()
                                        "http://tizen.org/feature/vision.inference.image",
                                        &isInferenceImageSupported);
 
-       if (nRetVal4 != SYSTEM_INFO_ERROR_NONE) {
+       if (nRetVal5 != SYSTEM_INFO_ERROR_NONE) {
                LOGE("SYSTEM_INFO_ERROR: vision.inference.image");
                return false;
        }
@@ -75,7 +75,7 @@ bool __mv_check_system_info_feature_supported()
                                        "http://tizen.org/feature/vision.inference.face",
                                        &isInferenceFaceSupported);
 
-       if (nRetVal4 != SYSTEM_INFO_ERROR_NONE) {
+       if (nRetVal6 != SYSTEM_INFO_ERROR_NONE) {
                LOGE("SYSTEM_INFO_ERROR: vision.inference.face");
                return false;
        }
index b0c9145..253d61a 100644 (file)
@@ -1,7 +1,7 @@
 Name:        capi-media-vision
 Summary:     Media Vision library for Tizen Native API
 Version:     0.5.0
-Release:     1
+Release:     2
 Group:       Multimedia/Framework
 License:     Apache-2.0 and BSD-3-Clause
 Source0:     %{name}-%{version}.tar.gz
index 68cbb6b..16ae6a4 100644 (file)
@@ -66,7 +66,7 @@ bool __mv_check_system_info_feature_supported()
                                        "http://tizen.org/feature/vision.inference.image",
                                        &isInferenceImageSupported);
 
-       if (nRetVal4 != SYSTEM_INFO_ERROR_NONE) {
+       if (nRetVal5 != SYSTEM_INFO_ERROR_NONE) {
                LOGE("SYSTEM_INFO_ERROR: vision.inference.image");
                return false;
        }
@@ -75,7 +75,7 @@ bool __mv_check_system_info_feature_supported()
                                        "http://tizen.org/feature/vision.inference.face",
                                        &isInferenceFaceSupported);
 
-       if (nRetVal4 != SYSTEM_INFO_ERROR_NONE) {
+       if (nRetVal6 != SYSTEM_INFO_ERROR_NONE) {
                LOGE("SYSTEM_INFO_ERROR: vision.inference.face");
                return false;
        }
index 962202f..f3a41cc 100644 (file)
@@ -874,6 +874,13 @@ int handle_tracking_image_result(
        }
 
        err = mv_source_get_colorspace(frame, &image_data.image_colorspace);
+       if (MEDIA_VISION_ERROR_NONE != err) {
+               printf(
+                               "ERROR: Errors were occurred during getting image colorspace from the "
+                               "source; code %i\n",
+                               err);
+               return err;
+       }
 
        if (location) {
                printf(
index 48cbb03..0f647c4 100644 (file)
@@ -759,11 +759,10 @@ int perform_image_classification()
                 int err2 = mv_destroy_source(mvSource);
                 if (err2 != MEDIA_VISION_ERROR_NONE) {
                     printf("Fail to destroy mvSource.\n", err2);
-                    free(in_file_name);
-                    return err2;
                 }
+                free(in_file_name);
+                break;
             }
-
             free(in_file_name);
 
             // Run
@@ -1006,7 +1005,7 @@ int perform_object_detection()
                     printf("Fail to destroy mvSource.\n", err2);
                 }
                 free(in_file_name);
-                return err2;
+                break;
             }
             free(in_file_name);
 
@@ -1243,7 +1242,7 @@ int perform_face_detection()
                     printf("Fail to destroy mvSource.\n", err2);
                 }
                 free(in_file_name);
-                return err2;
+                break;
             }
             free(in_file_name);
 
@@ -1472,7 +1471,7 @@ int perform_facial_landmark_detection()
                     printf("Fail to destroy mvSource.\n", err2);
                 }
                 free(in_file_name);
-                return err2;
+                break;
             }
             free(in_file_name);