From: saerome.kim Date: Fri, 27 Sep 2019 01:38:01 +0000 (+0900) Subject: Fixed svace issues. X-Git-Tag: accepted/tizen/unified/20190929.221439~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c7cec6f31a285d4771dbb6f5d060676f538b29ae;p=platform%2Fcore%2Fconnectivity%2Fua-manager.git Fixed svace issues. 410291: Potential Memory Leak. 410713: Handle leak of SQLLite statement. 401702, 410740, 410741: Memory leak. 410742: Missing null-check. Change-Id: I709b77dc29699c434e94bc5645455bcfdeb53bed Signed-off-by: saerome.kim --- diff --git a/packaging/ua-manager.spec b/packaging/ua-manager.spec index 10e1e2c..274dac7 100644 --- a/packaging/ua-manager.spec +++ b/packaging/ua-manager.spec @@ -1,6 +1,6 @@ Name: ua-manager Summary: User awareness manager -Version: 0.10.1 +Version: 0.10.2 Release: 1 License: Apache-2.0 Source0: %{name}-%{version}.tar.gz diff --git a/ua-daemon/src/pm/ua-light-plugin-handler.c b/ua-daemon/src/pm/ua-light-plugin-handler.c index e96e38b..9f0d4e7 100644 --- a/ua-daemon/src/pm/ua-light-plugin-handler.c +++ b/ua-daemon/src/pm/ua-light-plugin-handler.c @@ -62,6 +62,8 @@ void light_detection_callback(uas_detection_type_e type, void *sensor_info) _uam_core_handle_absence_detected(UAM_SENSOR_BITMASK_LIGHT, 0, light_info); } + g_free(light_info); + FUNC_EXIT; } diff --git a/ua-daemon/src/pm/ua-motion-plugin-handler.c b/ua-daemon/src/pm/ua-motion-plugin-handler.c index 39223dd..713a848 100644 --- a/ua-daemon/src/pm/ua-motion-plugin-handler.c +++ b/ua-daemon/src/pm/ua-motion-plugin-handler.c @@ -63,6 +63,8 @@ void motion_detection_callback(uas_detection_type_e type, void *sensor_info) _uam_core_handle_absence_detected(UAM_SENSOR_BITMASK_MOTION, 0, motion_info); } + g_free(motion_info); + FUNC_EXIT; } diff --git a/ua-daemon/src/ua-manager-core.c b/ua-daemon/src/ua-manager-core.c index 45f42e3..15786b7 100644 --- a/ua-daemon/src/ua-manager-core.c +++ b/ua-daemon/src/ua-manager-core.c @@ -2972,6 +2972,10 @@ int _uam_core_start_active_device_scan(char *sender, unsigned int sensors, int d } scanner = g_malloc0(sizeof(uam_scanner_info_t)); + if (scanner) { + UAM_ERR("Failed to allocate memory"); + return UAM_ERROR_OUT_OF_MEMORY; + } scanner->name = g_strdup(sender); scanner->sensors |= sensors; scanner->timer = g_timeout_add_seconds(detection_period, diff --git a/ua-daemon/src/ua-manager-db.c b/ua-daemon/src/ua-manager-db.c index 52a7685..4bb9e6a 100644 --- a/ua-daemon/src/ua-manager-db.c +++ b/ua-daemon/src/ua-manager-db.c @@ -165,6 +165,7 @@ static int __uam_db_get_version(unsigned int *ver) stmt = NULL; FINALIZE(select_version); UAM_ERR("Failed to prepare \"%s\" query", sql); + sqlite3_free(sql); return rc; } @@ -187,6 +188,8 @@ static int __uam_db_get_version(unsigned int *ver) FINALIZE(select_version); sqlite3_reset(stmt); + sqlite3_finalize(stmt); + sqlite3_free(sql); FUNC_EXIT; return error_code; } @@ -195,15 +198,20 @@ static int __uam_db_update_version(unsigned int version) { FUNC_ENTRY; char *sql = NULL; + int ret = UAM_ERROR_NONE; sql = sqlite3_mprintf("PRAGMA user_version = '%d';", version); - retv_if(UAM_ERROR_NONE != __uam_db_exec_sql(sql, NULL), UAM_ERROR_DB_FAILED); - sqlite3_free(sql); - UAM_DBG("Successfully updated database version to %d", version); + ret = __uam_db_exec_sql(sql, NULL); + if (UAM_ERROR_NONE != ret) + UAM_DBG("failed to updated database version to %d", version); + else + UAM_DBG("Successfully updated database version to %d", version); + + sqlite3_free(sql); FUNC_EXIT; - return UAM_ERROR_NONE; + return ret; } static int __uam_db_upgrade(unsigned int version) @@ -338,12 +346,16 @@ static int __uam_db_check_integrity(void) static int __uam_db_set_locking_mode(void) { char *sql = NULL; + int ret = UAM_ERROR_NONE; sql = sqlite3_mprintf("PRAGMA locking_mode = NORMAL"); - retv_if(UAM_ERROR_NONE != __uam_db_exec_sql(sql, NULL), UAM_ERROR_DB_FAILED); + ret = __uam_db_exec_sql(sql, NULL); + if (UAM_ERROR_NONE != ret) + ret = UAM_ERROR_DB_FAILED; + sqlite3_free(sql); - return UAM_ERROR_NONE; + return ret; } static int __uam_db_create_table(const char *table_name)