Fix static analysis issues 05/288705/2
authorInkyun Kil <inkyun.kil@samsung.com>
Wed, 22 Feb 2023 01:53:38 +0000 (10:53 +0900)
committerInkyun Kil <inkyun.kil@samsung.com>
Wed, 8 Mar 2023 07:59:39 +0000 (16:59 +0900)
Change-Id: I4b86a64035064f589303668b5ed65b3a81de8dbb
Signed-off-by: Inkyun Kil <inkyun.kil@samsung.com>
lib/alarm-lib.c
server/alarm-manager-db.cc
server/alarm-manager-util.c

index c8ee73d..d1e06e0 100644 (file)
@@ -460,7 +460,7 @@ static int __compare_api_version(int *result, uid_t uid)
        int ret = 0;
        pkgmgrinfo_pkginfo_h pkginfo = NULL;
        char pkgid[MAX_PKG_ID_LEN] = {0, };
-       char *pkg_version;
+       char *pkg_version = NULL;
 
        if (aul_app_get_pkgid_bypid_for_uid(getpid(), pkgid, sizeof(pkgid), uid) != AUL_R_OK) {
                LOGE("aul_app_get_pkgid_bypid() is failed. PID %d may not be app.", getpid());
@@ -470,8 +470,11 @@ static int __compare_api_version(int *result, uid_t uid)
                        LOGE("Failed to get pkginfo\n");
                } else {
                        ret = pkgmgrinfo_pkginfo_get_api_version(pkginfo, &pkg_version);
-                       if (ret != PMINFO_R_OK)
+                       if (ret != PMINFO_R_OK) {
                                LOGE("Failed to check api version [%d]\n", ret);
+                               pkgmgrinfo_pkginfo_destroy_pkginfo(pkginfo);
+                               return ret;
+                       }
 
                        *result = strverscmp(pkg_version, "2.4");
                        pkgmgrinfo_pkginfo_destroy_pkginfo(pkginfo);
index b8e1c72..ccd9cc3 100644 (file)
@@ -90,7 +90,7 @@ char* GetCString(int idx, const tizen_base::Database::Result::Record& rec,
     return nullptr;
 
   if (max_size > 0) {
-    strdup(str->substr(max_size).c_str());
+    return strdup(str->substr(max_size).c_str());
   }
 
   return strdup(str->c_str());
index 8533a9c..6d283d5 100644 (file)
@@ -55,7 +55,7 @@ int _pkg_is_global(const char *callee_pkgid, uid_t uid)
 {
        int retval;
        int return_code = ERR_ALARM_SYSTEM_FAIL;
-       pkgmgrinfo_pkginfo_h handle;
+       pkgmgrinfo_pkginfo_h handle = NULL;
 
        retval = pkgmgrinfo_pkginfo_get_usr_pkginfo(callee_pkgid, uid, &handle);
        if (retval != PMINFO_R_OK) {
@@ -199,9 +199,9 @@ int _get_pid_from_appid(const char *app_id, uid_t uid)
 
 char *_get_pkgid_by_appid(const char *app_id, uid_t uid)
 {
-       pkgmgrinfo_pkginfo_h handle;
+       pkgmgrinfo_pkginfo_h handle = NULL;
        char *pkgid = NULL;
-       char *temp;
+       char *temp = NULL;
 
        if (pkgmgrinfo_appinfo_get_usr_appinfo(app_id, uid, &handle) == PMINFO_R_OK) {
                if (pkgmgrinfo_appinfo_get_pkgid(handle, &temp) == PMINFO_R_OK) {
@@ -258,7 +258,7 @@ int _compare_api_version(int *result, int pid, uid_t uid)
        int ret = 0;
        pkgmgrinfo_pkginfo_h pkginfo = NULL;
        char pkgid[MAX_PKG_ID_LEN] = {0, };
-       char *pkg_version;
+       char *pkg_version = NULL;
 
        if (aul_app_get_pkgid_bypid_for_uid(pid, pkgid, sizeof(pkgid), uid) != AUL_R_OK) {
                LOGE("aul_app_get_pkgid_bypid() is failed. PID %d may not be app.", getpid());
@@ -288,7 +288,7 @@ bool _permit_by_config(pkgmgrinfo_appinfo_h handle, uid_t uid)
        if (access(tzplatform_mkpath(TZ_SYS_RO_SHARE,
                                        "alarm-manager/alarm-config-platform-service-permitted"), F_OK) == 0) {
                LOGD("This profile permit alarm for service applications which has platform cert\n");
-               char *pkgid;
+               char *pkgid = NULL;
                int r;
                const char *cert_value;
                pkgmgrinfo_certinfo_h certinfo;