Fix SVACE: FORWARD_NULL && BAD_COMPARE detect 12/324412/5
authorLe <xuan.tien@samsung.com>
Fri, 16 May 2025 10:17:52 +0000 (17:17 +0700)
committerTien Le <xuan.tien@samsung.com>
Mon, 19 May 2025 06:29:09 +0000 (06:29 +0000)
Change-Id: Ib422e74f99077a61c55751ecbda8d0c890c66341
Signed-off-by: Le <xuan.tien@samsung.com>
test/tc-privilege-info.c
test/tc-privilege-package-info.c

index 4381c944fec6603531816630f9889494bc10ed54..6059021e93bb4ce7d1ea70fddde267bb705af41a 100644 (file)
@@ -62,7 +62,7 @@ static void __check_get_privilege_description_result(privilege_manager_error_e e
                                printf_red("test fail\n");
                                fail_cnt++;
                                return;
-                       }else if(strcmp(description, expected_description) == 0){
+                       } else if((description != NULL && expected_description != NULL) && strcmp(description, expected_description) == 0){
                                printf("matched\n");
                                printf_green("test success\n");
                                success_cnt++;
@@ -482,7 +482,8 @@ void __test_privilege_info_get_privilege_description()
        expected_description = "IDS_TPLATFORM_BODY_THIS_APPLICATION_CAN_READ_ACCOUNTS";
        ret = privilege_info_get_privilege_description("http://tizen.org/privilege/account.read", &description);
        __check_get_privilege_description_result(PRVMGR_ERR_NONE, ret, description, expected_description);
-       SafeFree(description);
+       free(description);
+       description = NULL;
        __print_line();
 
        __tcinfo(goal, NEG_TC_PREFIX "__test_privilege_info_get_privilege_description with wrong parameter");
@@ -490,7 +491,8 @@ void __test_privilege_info_get_privilege_description()
        expected_description = NULL;
        ret = privilege_info_get_privilege_description("http://tizen.org/privilege/badge.admin", &description);
        __check_get_privilege_description_result(PRVMGR_ERR_NONE, ret, description, expected_description);
-       SafeFree(description);
+       free(description);
+       description = NULL;
        __print_line();
 
        __tcinfo(goal, NEG_TC_PREFIX "__test_privilege_info_get_privilege_description with invalid parameter");
@@ -498,14 +500,15 @@ void __test_privilege_info_get_privilege_description()
        expected_description = NULL;
        ret = privilege_info_get_privilege_description("http://tizen.org/privilege/accousdfsdnt.resdfsdfad", &description);
        __check_get_privilege_description_result(PRVMGR_ERR_NONE, ret, description, expected_description);
-       SafeFree(description);
+       free(description);
+       description = NULL;
        __print_line();
 
        __tcinfo(goal, NEG_TC_PREFIX "__test_privilege_info_get_privilege_description with null parameter");
        ret = privilege_info_get_privilege_description(NULL, &description);
        __check_get_privilege_description_result(PRVMGR_ERR_INVALID_PARAMETER, ret, description, expected_description);
-       SafeFree(description);
-       SafeFree(expected_description);
+       free(description);
+       free(expected_description);
        __print_line();
 }
 
@@ -964,7 +967,8 @@ void __test_privilege_info_get_privilege_description_by_package_type()
                PRVMGR_PACKAGE_TYPE_CORE,
                &description);
        __check_get_privilege_description_result(PRVMGR_ERR_NONE, ret, description, expected_description);
-       SafeFree(description);
+       free(description);
+       description = NULL;
        __print_line();
 
        __tcinfo(goal, NEG_TC_PREFIX "__test_privilege_info_get_privilege_description_by_package_type with invalid privilege");
@@ -976,7 +980,7 @@ void __test_privilege_info_get_privilege_description_by_package_type()
                PRVMGR_PACKAGE_TYPE_CORE,
                &description);
        __check_get_privilege_description_result(PRVMGR_ERR_NO_EXIST_PRIVILEGE, ret, description, expected_description);
-       SafeFree(description);
+       free(description);
        __print_line();
 
        __tcinfo(goal, NEG_TC_PREFIX "__test_privilege_info_get_privilege_description_by_package_type with null privilege");
@@ -988,7 +992,7 @@ void __test_privilege_info_get_privilege_description_by_package_type()
                PRVMGR_PACKAGE_TYPE_CORE,
                &description);
        __check_get_privilege_description_result(PRVMGR_ERR_INVALID_PARAMETER, ret, description, expected_description);
-       SafeFree(description);
+       free(description);
        __print_line();
 
        __tcinfo(goal, NEG_TC_PREFIX "__test_privilege_info_get_privilege_description_by_package_type with PRVMGR_PACKAGE_TYPE_NONE");
@@ -1000,7 +1004,7 @@ void __test_privilege_info_get_privilege_description_by_package_type()
                PRVMGR_PACKAGE_TYPE_NONE,
                &description);
        __check_get_privilege_description_result(PRVMGR_ERR_INVALID_PARAMETER, ret, description, expected_description);
-       SafeFree(description);
+       free(description);
        __print_line();
 }
 
@@ -1021,7 +1025,8 @@ void __test_privilege_info_get_privilege_display_name_by_package_type()
                PRVMGR_PACKAGE_TYPE_CORE,
                &display_name);
        __check_get_privilege_display_name_result(PRVMGR_ERR_NONE, ret, display_name, expected_display_name);
-       SafeFree(display_name);
+       free(display_name);
+       display_name = NULL;
        expected_display_name = NULL;
        __print_line();
 
@@ -1034,7 +1039,7 @@ void __test_privilege_info_get_privilege_display_name_by_package_type()
                PRVMGR_PACKAGE_TYPE_CORE,
                &display_name);
        __check_get_privilege_display_name_result(PRVMGR_ERR_NO_EXIST_PRIVILEGE, ret, display_name, expected_display_name);
-       SafeFree(display_name);
+       free(display_name);
        __print_line();
 
        __tcinfo(goal, NEG_TC_PREFIX "__test_privilege_info_get_privilege_display_name_by_package_type with null privilege");
@@ -1042,7 +1047,7 @@ void __test_privilege_info_get_privilege_display_name_by_package_type()
        printf("privilege : NULL\n");
        ret = privilege_info_get_privilege_display_name_by_package_type(NULL, "2.3", PRVMGR_PACKAGE_TYPE_CORE, &display_name);
        __check_get_privilege_display_name_result(PRVMGR_ERR_INVALID_PARAMETER, ret, display_name, expected_display_name);
-       SafeFree(display_name);
+       free(display_name);
        __print_line();
 
        __tcinfo(goal, NEG_TC_PREFIX "__test_privilege_info_get_privilege_display_name_by_package_type with PRVMGR_PACKAGE_TYPE_NONE");
@@ -1050,7 +1055,7 @@ void __test_privilege_info_get_privilege_display_name_by_package_type()
        printf("privilege : NULL\n");
        ret = privilege_info_get_privilege_display_name_by_package_type(NULL, "2.3", PRVMGR_PACKAGE_TYPE_NONE, &display_name);
        __check_get_privilege_display_name_result(PRVMGR_ERR_INVALID_PARAMETER, ret, display_name, expected_display_name);
-       SafeFree(display_name);
+       free(display_name);
        __print_line();
 }
 
index 36d3a4278c45dc420f79c57755e277fe97bb11d0..4b3cff4bfab5187ff7aeab4a3faa044c9d824899 100644 (file)
@@ -21,7 +21,7 @@ void __test_privilege_package_info()
        bool is_requestable;
        bool expect_result;
 
-       printf("ENABLE ASKUSER: %s\n", ENABLE_ASKUSER ? "True" : "False");
+       printf("ENABLE ASKUSER: %s\n", (bool) ENABLE_ASKUSER ? "True" : "False");
        __set_privacy_test_pkg_info();
 
        /* Native api-version 3.0 */
@@ -113,7 +113,7 @@ void __test_privilege_package_info()
 
        __tcinfo(goal, POS_TC_PREFIX "see if uid 5001, api-version=4.0, org.test.webapp_4 can request privacy for http://tizen.org/privilege/call");
        ret = privilege_package_info_is_privacy_requestable(5001, "org.test.webapp_4", "http://tizen.org/privilege/call", &is_requestable);
-       expect_result = (ret == PRVMGR_ERR_NONE && ENABLE_ASKUSER == is_requestable);
+       expect_result = (ret == PRVMGR_ERR_NONE && (bool) ENABLE_ASKUSER == is_requestable);
        __output_privilege_package_info_is_privacy_requestable(expect_result, is_requestable, ret);
 
        __tcinfo(goal, POS_TC_PREFIX "see if uid 5001, api-version=4.0, org.test.webapp_4 can request privacy for http://tizen.org/privilege/mediastorage");
@@ -123,12 +123,12 @@ void __test_privilege_package_info()
 
        __tcinfo(goal, POS_TC_PREFIX "see if uid 5001, api-version=5.0, org.test.webapp_5 can request privacy for http://tizen.org/privilege/mediastorage");
        ret = privilege_package_info_is_privacy_requestable(5001, "org.test.webapp_5", "http://tizen.org/privilege/mediastorage", &is_requestable);
-       expect_result = (ret == PRVMGR_ERR_NONE && ENABLE_ASKUSER == is_requestable);
+       expect_result = (ret == PRVMGR_ERR_NONE && (bool) ENABLE_ASKUSER == is_requestable);
        __output_privilege_package_info_is_privacy_requestable(expect_result, is_requestable, ret);
 
        __tcinfo(goal, POS_TC_PREFIX "[Handle api_version >= 10] see if uid 5001, api-version=10.0, org.test.nativeapp_10 can request privacy for http://tizen.org/privilege/mediastorage");
        ret = privilege_package_info_is_privacy_requestable(5001, "org.test.nativeapp_10", "http://tizen.org/privilege/mediastorage", &is_requestable);
-       expect_result = (ret == PRVMGR_ERR_NONE && ENABLE_ASKUSER == is_requestable);
+       expect_result = (ret == PRVMGR_ERR_NONE && (bool) ENABLE_ASKUSER == is_requestable);
        __output_privilege_package_info_is_privacy_requestable(expect_result, is_requestable, ret);
 
        __tcinfo(goal, POS_TC_PREFIX "[Handle api_version >= 10] see if uid 5001, api-version=10.0, org.test.nativeapp_10 can request privacy for http://tizen.org/privilege/internet");