if (ret != SQLITE_OK) {
_LOGE("Don't execute query = %s error message = %s\n", query,
sqlite3_errmsg(db));
+ sqlite3_close_v2(db);
free(dbpath);
return -1;
}
while (sqlite3_step(stmt) == SQLITE_ROW) {
+ type = NULL;
update_info = calloc(1, sizeof(updateinfo_x));
if (update_info == NULL) {
_LOGE("Out of memory");
_save_column_str(stmt, idx++, &update_info->version);
_save_column_str(stmt, idx, &type);
ret = __convert_update_type(type, &convert_type);
+ free(type);
if (ret != 0) {
__free_update_info(update_info);
free(dbpath);
return -1;
}
update_info->type = convert_type;
- *update_info_list = g_slist_append(*update_info_list, update_info);
+ *update_info_list = g_slist_prepend(*update_info_list,
+ update_info);
}
free(dbpath);
int ret;
pkgmgrinfo_pkginfo_h pkginfo = NULL;
bool is_global_pkg;
- updateinfo_x *update_info;
GSList *info_list = NULL;
if (update_handle == NULL || pkgid == NULL)
return PMINFO_R_EINVAL;
- update_info = calloc(1, sizeof(updateinfo_x));
- if (update_info == NULL) {
- _LOGE("Out of memory");
- return PMINFO_R_ERROR;
- }
-
ret = pkgmgrinfo_pkginfo_get_usr_pkginfo(pkgid, uid, &pkginfo);
- if (ret != PMINFO_R_OK) {
- free(update_info);
+ if (ret != PMINFO_R_OK)
return ret;
- }
+
ret = pkgmgrinfo_pkginfo_is_global(pkginfo, &is_global_pkg);
if (ret != PMINFO_R_OK) {
- free(update_info);
pkgmgrinfo_pkginfo_destroy_pkginfo(pkginfo);
return ret;
}
pkgmgrinfo_foreach_updateinfo_cb callback, void *user_data)
{
int ret;
- GSList *info_list;
+ GSList *info_list = NULL;
GSList *tmp_list;
if (callback == NULL)
return PMINFO_R_EINVAL;
- info_list = calloc(1, sizeof(updateinfo_x));
- if (info_list == NULL) {
- _LOGE("Out of memory");
- return PMINFO_R_ERROR;
- }
-
ret = _get_pkg_updateinfo_from_db(NULL, &info_list, uid);
if (ret != 0) {
_LOGE("Failed to get pkg update info for user[%d]", (int)uid);
- pkgmgrinfo_updateinfo_destroy(info_list);
+ g_slist_free_full(info_list, __free_update_info);
return PMINFO_R_ERROR;
}
if (ret != 0) {
_LOGE("Failed to get pkg update info for user[%d]",
(int)GLOBAL_USER);
- pkgmgrinfo_updateinfo_destroy(info_list);
+ g_slist_free_full(info_list, __free_update_info);
return PMINFO_R_ERROR;
}