From 705a12d3ef9d93f2c60e70e0405e0de893b67a47 Mon Sep 17 00:00:00 2001 From: Junghyun Yeon Date: Wed, 7 Dec 2016 14:30:28 +0900 Subject: [PATCH] Fix static analysis tool issue - Remove unreachable code - fix memory leak Change-Id: Ia7ad1372fde5acc89dc6e2657368491c8c2b8da2 Signed-off-by: Junghyun Yeon --- plugin/app2sd/server/app2sd_internals_registry.c | 4 ++-- plugin/app2sd/server/app2sd_server.c | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/plugin/app2sd/server/app2sd_internals_registry.c b/plugin/app2sd/server/app2sd_internals_registry.c index 846d121..42ee967 100644 --- a/plugin/app2sd/server/app2sd_internals_registry.c +++ b/plugin/app2sd/server/app2sd_internals_registry.c @@ -312,8 +312,8 @@ char *_app2sd_get_password_from_db(const char *pkgid, uid_t uid) strncpy(passwd, (const char *)sqlite3_column_text(stmt, 1), PASSWORD_LENGTH); - if (passwd == NULL) { - _E("data is NULL"); + if (strlen(passwd) == 0) { + _E("data is empty"); goto FINISH_OFF; } if (SQLITE_OK != sqlite3_finalize(stmt)) { diff --git a/plugin/app2sd/server/app2sd_server.c b/plugin/app2sd/server/app2sd_server.c index cd863af..61977c7 100644 --- a/plugin/app2sd/server/app2sd_server.c +++ b/plugin/app2sd/server/app2sd_server.c @@ -28,6 +28,15 @@ guint source_id; GMainLoop *app2sd_mainloop = NULL; +static void __free_dir_detail(gpointer data) +{ + app2ext_dir_details *dir_detail = (app2ext_dir_details *)data; + + if (dir_detail->name) + free(dir_detail->name); + free(dir_detail); +} + gboolean __exit_app2sd_server(void *data) { if (processing_busy_cnt <= 0) { @@ -272,6 +281,7 @@ static void _app2sd_server_pre_app_install(GDBusConnection *connection, const gc _E("error(%d)", ret); result = ret; } + g_list_free_full(dir_list, __free_dir_detail); param = g_variant_new("(i)", result); g_dbus_method_invocation_return_value(invocation, param); @@ -370,6 +380,7 @@ static void _app2sd_server_pre_app_upgrade(GDBusConnection *connection, const gc _E("error(%d)", ret); result = ret; } + g_list_free_full(dir_list, __free_dir_detail); param = g_variant_new("(i)", result); g_dbus_method_invocation_return_value(invocation, param); @@ -594,6 +605,7 @@ static void _app2sd_server_pre_move_installed_app(GDBusConnection *connection, result = ret; } + g_list_free_full(list, __free_dir_detail); param = g_variant_new("(i)", result); g_dbus_method_invocation_return_value(invocation, param); } -- 2.7.4