[SVACE Issues Fixed] 32/172732/4
authorAbhishek Vijay <abhishek.v@samsung.com>
Thu, 15 Mar 2018 11:59:09 +0000 (17:29 +0530)
committerAbhishek Vijay <abhishek.v@samsung.com>
Fri, 23 Mar 2018 05:44:38 +0000 (05:44 +0000)
Signed-off-by: Abhishek Vijay <abhishek.v@samsung.com>
Change-Id: Id879e99a8b1f8586105d9aa3d619426246f0932b

common/src/account_db_helper.c

index d837324..4a707fe 100644 (file)
@@ -1454,6 +1454,7 @@ int _account_delete_account_by_package_name(sqlite3 *account_db_handle, const ch
 
        /* It only needs list of ids, does not need to query sensitive info. So sending 0 */
        GList *account_list_temp = _account_query_account_by_package_name(account_db_handle, package_name, &ret, pid, uid);
+
        if (_account_db_err_code(account_db_handle) == SQLITE_PERM) {
                ACCOUNT_ERROR("Access failed(%s)", _account_db_err_msg(account_db_handle));
                return _ACCOUNT_ERROR_PERMISSION_DENIED;
@@ -1526,14 +1527,17 @@ int _account_delete_account_by_package_name(sqlite3 *account_db_handle, const ch
 
        if (_account_db_err_code(account_db_handle) == SQLITE_PERM) {
                ACCOUNT_ERROR("Access failed(%s)", _account_db_err_msg(account_db_handle));
+               g_slist_free_full(account_id_list, g_free);
                return _ACCOUNT_ERROR_PERMISSION_DENIED;
        }
 
        if (ret_transaction == _ACCOUNT_ERROR_DATABASE_BUSY) {
                ACCOUNT_ERROR("database busy(%s)", _account_db_err_msg(account_db_handle));
+               g_slist_free_full(account_id_list, g_free);
                return _ACCOUNT_ERROR_DATABASE_BUSY;
        } else if (ret_transaction != _ACCOUNT_ERROR_NONE) {
                ACCOUNT_ERROR("account_delete:_account_begin_transaction fail %d\n", ret_transaction);
+               g_slist_free_full(account_id_list, g_free);
                return ret_transaction;
        }
 
@@ -1547,6 +1551,7 @@ int _account_delete_account_by_package_name(sqlite3 *account_db_handle, const ch
        if (_account_db_err_code(account_db_handle) == SQLITE_PERM) {
                _account_end_transaction(account_db_handle, false);
                ACCOUNT_ERROR("Access failed(%s)", _account_db_err_msg(account_db_handle));
+               g_slist_free_full(account_id_list, g_free);
                return _ACCOUNT_ERROR_PERMISSION_DENIED;
        }
 
@@ -1560,7 +1565,8 @@ int _account_delete_account_by_package_name(sqlite3 *account_db_handle, const ch
        ACCOUNT_CATCH_ERROR(rc == SQLITE_DONE, {}, _ACCOUNT_ERROR_RECORD_NOT_FOUND, ("The record isn't found.\n"));
 
        rc = _account_query_finalize(hstmt);
-       ACCOUNT_RETURN_VAL((rc == _ACCOUNT_ERROR_NONE), { _account_end_transaction(account_db_handle, false); }, rc, ("finalize error"));
+       ACCOUNT_RETURN_VAL((rc == _ACCOUNT_ERROR_NONE),
+               { _account_end_transaction(account_db_handle, false); g_slist_free_full(account_id_list, g_free); }, rc, ("finalize error"));
        hstmt = NULL;
 
        _INFO("start delete capability table");
@@ -1580,7 +1586,8 @@ int _account_delete_account_by_package_name(sqlite3 *account_db_handle, const ch
        ACCOUNT_CATCH_ERROR(rc == SQLITE_DONE, {}, _ACCOUNT_ERROR_RECORD_NOT_FOUND, ("The record isn't found.\n"));
 
        rc = _account_query_finalize(hstmt);
-       ACCOUNT_RETURN_VAL((rc == _ACCOUNT_ERROR_NONE), { _account_end_transaction(account_db_handle, false); }, rc, ("finalize error"));
+       ACCOUNT_RETURN_VAL((rc == _ACCOUNT_ERROR_NONE),
+               { _account_end_transaction(account_db_handle, false); g_slist_free_full(account_id_list, g_free); }, rc, ("finalize error"));
        hstmt = NULL;
 
        _INFO("start delete account table");
@@ -1600,7 +1607,8 @@ int _account_delete_account_by_package_name(sqlite3 *account_db_handle, const ch
        ACCOUNT_CATCH_ERROR(rc == SQLITE_DONE, {}, _ACCOUNT_ERROR_RECORD_NOT_FOUND, ("The record isn't found. package_name=%s, rc=%d\n", package_name, rc));
 
        rc = _account_query_finalize(hstmt);
-       ACCOUNT_RETURN_VAL((rc == _ACCOUNT_ERROR_NONE), { _account_end_transaction(account_db_handle, false); }, rc, ("finalize error"));
+       ACCOUNT_RETURN_VAL((rc == _ACCOUNT_ERROR_NONE),
+               { _account_end_transaction(account_db_handle, false); g_slist_free_full(account_id_list, g_free); }, rc, ("finalize error"));
        is_success = TRUE;
 
        hstmt = NULL;
@@ -1608,7 +1616,8 @@ int _account_delete_account_by_package_name(sqlite3 *account_db_handle, const ch
 CATCH:
        if (hstmt != NULL) {
                rc = _account_query_finalize(hstmt);
-               ACCOUNT_RETURN_VAL((rc == _ACCOUNT_ERROR_NONE), { _account_end_transaction(account_db_handle, false); }, rc, ("finalize error"));
+               ACCOUNT_RETURN_VAL((rc == _ACCOUNT_ERROR_NONE),
+                       { _account_end_transaction(account_db_handle, false); g_slist_free_full(account_id_list, g_free); }, rc, ("finalize error"));
                hstmt = NULL;
        }