diff options
author | Hwankyu Jhun <h.jhun@samsung.com> | 2017-01-23 11:37:16 +0900 |
---|---|---|
committer | Hwankyu Jhun <h.jhun@samsung.com> | 2017-01-23 12:52:02 +0900 |
commit | 1479830043f3833ad4ff07a5a5317b8e1aec17e2 (patch) | |
tree | 513699b5f76e163d67574393df4142aacde9332f | |
parent | 509d6ba02e3b93fa9d87b186dd2fd3a51b9b3bbd (diff) | |
download | widget-service-1479830043f3833ad4ff07a5a5317b8e1aec17e2.tar.gz widget-service-1479830043f3833ad4ff07a5a5317b8e1aec17e2.tar.bz2 widget-service-1479830043f3833ad4ff07a5a5317b8e1aec17e2.zip |
Fix memory leak
Change-Id: I4fe31da58dcee7baa4f3029470d37749a3a8de71
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
-rw-r--r-- | src/widget_instance.c | 31 | ||||
-rw-r--r-- | src/widget_service.c | 7 |
2 files changed, 34 insertions, 4 deletions
diff --git a/src/widget_instance.c b/src/widget_instance.c index bf2e8a8..fe012e6 100644 --- a/src/widget_instance.c +++ b/src/widget_instance.c @@ -244,8 +244,11 @@ static void __remove_instance(struct _widget_instance *instance) app->instances = g_list_remove(app->instances, instance); if (app->instances == NULL) { _widget_apps = g_list_remove(_widget_apps, app); + if (app->widget_id) + free(app->widget_id); + if (app->viewer_id) + free(app->viewer_id); free(app); - app = NULL; } } @@ -880,6 +883,10 @@ EAPI int widget_instance_init(const char *viewer_id) EAPI int widget_instance_fini() { + if (lifecycle_tbl) { + g_hash_table_destroy(lifecycle_tbl); + lifecycle_tbl = NULL; + } if (conn_viewer) { if (aul_app_com_leave(conn_viewer) < 0) @@ -896,6 +903,11 @@ EAPI int widget_instance_fini() viewer_appid = NULL; } + if (package_id) { + free(package_id); + package_id = NULL; + } + return 0; } @@ -1128,6 +1140,18 @@ EAPI int widget_instance_unlisten_event(widget_instance_event_cb cb) return -1; } +static void __destroy_lifecycle_local(gpointer data) +{ + struct lifecycle_local_s *cb_info = (struct lifecycle_local_s *)data; + + if (cb_info == NULL) + return; + + if (cb_info->widget_id) + free(cb_info->widget_id); + free(cb_info); +} + /* within package only */ EAPI int widget_instance_listen_status(const char *widget_id, widget_instance_event_cb cb, void *data) { @@ -1146,7 +1170,8 @@ EAPI int widget_instance_listen_status(const char *widget_id, widget_instance_ev cb_info->cb = cb; cb_info->data = data; if (!lifecycle_tbl) { - lifecycle_tbl = g_hash_table_new(g_str_hash, g_str_equal); + lifecycle_tbl = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, + __destroy_lifecycle_local); if (!lifecycle_tbl) { free(cb_info); return -1; @@ -1172,8 +1197,6 @@ EAPI int widget_instance_unlisten_status(const char *widget_id) return -1; g_hash_table_remove(lifecycle_tbl, widget_id); - free(cb_info->widget_id); - free(cb_info); return 0; } diff --git a/src/widget_service.c b/src/widget_service.c index 2b3600f..170a752 100644 --- a/src/widget_service.c +++ b/src/widget_service.c @@ -303,8 +303,10 @@ static int _resolution_update_from_file(void) dic = iniparser_load(file_path); if (dic == NULL) { _E("fail to load [%s] ", file_path); + free(file_path); return WIDGET_ERROR_IO_ERROR; } + free(file_path); snprintf(key_format, sizeof(key_format), "%s:%s", RESOLUTION_SECTION_NAME, RESOLUTION_FORMAT); key_num = iniparser_getsecnkeys(dic, RESOLUTION_SECTION_NAME); @@ -484,6 +486,8 @@ static int _get_widget_supported_sizes(const char *widget_id, uid_t uid, _E("failed to convert size"); free(width); free(height); + sqlite3_finalize(stmt); + sqlite3_close_v2(db); return WIDGET_ERROR_FAULT; } *w = width; @@ -629,6 +633,8 @@ static int _get_widget_list(const char *pkgid, uid_t uid, GList **list) if (item == NULL) { /* LCOV_EXCL_START */ _E("out of memory"); + sqlite3_finalize(stmt); + sqlite3_close_v2(db); return WIDGET_ERROR_OUT_OF_MEMORY; /* LCOV_EXCL_STOP */ } @@ -1760,6 +1766,7 @@ EAPI int widget_service_get_content_of_widget_instance(const char *widget_id, co ret = aul_widget_instance_get_content(widget_id, widget_instance_id, &raw); if (raw) { *b = bundle_decode((const bundle_raw *)raw, strlen(raw)); + free(raw); return WIDGET_ERROR_NONE; } |