Fix bugs 97/271497/4 accepted/tizen/unified/20220224.133705 submit/tizen/20220224.031004
authorTae-Young Chung <ty83.chung@samsung.com>
Tue, 22 Feb 2022 06:30:50 +0000 (15:30 +0900)
committerTae-Young Chung <ty83.chung@samsung.com>
Tue, 22 Feb 2022 08:44:38 +0000 (17:44 +0900)
[Version] 0.12.4-0
[Issue type] bug fix

1. Fix INVARIANT_RESULT.OP_ZERO
 - In case of GetLandmarkType(), its' return values are limited to the
landmark type enumeration so that checking the return value of
GetLandmarkType() is meaningless
2. Check null after malloc()
3. Initialize member variable in class ctor

Change-Id: I0e23298ffcb7760eb86e24e37347eae5e992e421
Signed-off-by: Tae-Young Chung <ty83.chung@samsung.com>
mv_face/face/src/mv_face_open.cpp
mv_machine_learning/mv_inference/inference/src/PoseDecoder.cpp
packaging/capi-media-vision.spec
test/testsuites/image/image_test_suite.c
test/testsuites/machine_learning/inference/test_inference_helper.cpp
test/testsuites/surveillance/surveillance_test_suite.c

index 443fd715323a37d819eb384e2cef524ff8e8cdeb..fb4496b37ed9fa586ebd20e7654697e63f130b54 100644 (file)
@@ -694,19 +694,21 @@ int mv_face_recognition_model_query_labels_open(
                                static_cast<FaceRecognitionModel*>(recognition_model);
 
        const std::set<int>& learnedLabels = pRecModel->getFaceLabels();
-       *number_of_labels = learnedLabels.size();
-
-       if ((*number_of_labels)) {
-               (*labels) = (int*)malloc(sizeof(int) * (*number_of_labels));
-
-               std::set<int>::const_iterator it = learnedLabels.begin();
-               int i = 0;
-               for (; it != learnedLabels.end(); ++it) {
-                       (*labels)[i] = *it;
-                       ++i;
+       auto _number_of_labels = learnedLabels.size();
+       int *_pLabels = NULL;
+       if (_number_of_labels) {
+               _pLabels = (int*)malloc(sizeof(int) * (_number_of_labels));
+               if(_pLabels == NULL) {
+                       LOGE("Fail to alloc memory for %zu labels", _number_of_labels);
+                       return MEDIA_VISION_ERROR_OUT_OF_MEMORY;
                }
+
+               std::copy(learnedLabels.begin(), learnedLabels.end(), _pLabels);
        }
 
+       *number_of_labels = _number_of_labels;
+       *labels = _pLabels;
+
        LOGD("List of the labels learned by the recognition model has been retrieved");
        return MEDIA_VISION_ERROR_NONE;
 }
index e1596aaeebe2e101032515f7399d3803243138b4..09c10d880b25923e839d0a184acc26765b52a0dc 100644 (file)
@@ -50,12 +50,6 @@ namespace inference
        {
                LOGI("ENTER");
 
-               if (mMeta.GetLandmarkType() < INFERENCE_LANDMARK_TYPE_2D_SINGLE ||
-                       mMeta.GetLandmarkType() > INFERENCE_LANDMARK_TYPE_3D_SINGLE) {
-                       LOGE("Not supported landmark type");
-                       return MEDIA_VISION_ERROR_INVALID_OPERATION;
-               }
-
                if (mMeta.GetLandmarkDecodingType() == INFERENCE_LANDMARK_DECODING_TYPE_BYPASS ||
                        mMeta.GetLandmarkDecodingType() == INFERENCE_LANDMARK_DECODING_TYPE_BYPASS_MULTICHANNEL) {
                        LOGI("Skip init");
index 7bb69887994714eabce048703efac0d3b7417cde..a8cd2a94ea6083d46debc118427268059030dec8 100644 (file)
@@ -1,6 +1,6 @@
 Name:        capi-media-vision
 Summary:     Media Vision library for Tizen Native API
-Version:     0.12.3
+Version:     0.12.4
 Release:     0
 Group:       Multimedia/Framework
 License:     Apache-2.0 and BSD-3-Clause
index f1ff0defb0a16721d1319ffbad8ee9a3c6d8d4b8..a18ef5a43a69facb8f47dd7278f2b377e7724780 100644 (file)
@@ -1742,6 +1742,10 @@ void perform_recognition_cases(GArray *image_objects)
                        }
 
                        mv_image_object_h *objects_pool = malloc(sizeof(mv_image_object_h) * image_objects->len);
+                       if (objects_pool == NULL) {
+                               printf("\nFail to alloc memory for %u objects.\n", image_objects->len);
+                               break;
+                       }
                        int index = 0;
                        for (; index < image_objects->len; ++index)
                                objects_pool[index] = g_array_index(image_objects, testing_object_h, index)->entity;
index c041f486a33587c46f3f7175cb44e56f3756ab7a..ac427e6df21fea83b0783bc67a92601c47459647 100644 (file)
@@ -2,7 +2,8 @@
 #include <image_helper.h>
 #include "test_inference_helper.hpp"
 
-TestInference::TestInference()
+TestInference::TestInference() :
+               _use_json_parser(false)
 {
        EXPECT_EQ(mv_create_engine_config(&engine_cfg), MEDIA_VISION_ERROR_NONE);
        EXPECT_EQ(mv_inference_create(&infer), MEDIA_VISION_ERROR_NONE);
index 0a86b9853a76cb988a38453cbd8d8628ce539dca..5b7810c074672343f8fd1646c0390f00ec5c8fb0 100644 (file)
@@ -454,6 +454,10 @@ void add_roi_to_event(mv_surveillance_event_trigger_h event_trigger)
                PRINT_R("Incorrect input! Try again.");
 
        mv_point_s* roi = (mv_point_s*) malloc(sizeof(mv_point_s) * number_of_roi_points);
+       if (roi == NULL) {
+               PRINT_E("Fail to alloc roi err[%d].", MEDIA_VISION_ERROR_OUT_OF_MEMORY);
+               return;
+       }
 
        int x = 0;
        int y = 0;