From 7833b656b6dd2c226b87c207b4e5bcd5238005a2 Mon Sep 17 00:00:00 2001 From: Wonnam Jang Date: Wed, 29 Nov 2017 21:20:01 +0900 Subject: [PATCH] check null before use when dbus close connection Change-Id: I00e45405980dfcd1572afa428f5937688a0aee94 Signed-off-by: Wonnam Jang --- client/vc_dbus.c | 18 ++++++++++-------- client/vc_mgr_dbus.c | 18 ++++++++++-------- client/vc_widget_dbus.c | 18 ++++++++++-------- 3 files changed, 30 insertions(+), 24 deletions(-) diff --git a/client/vc_dbus.c b/client/vc_dbus.c index 7ab57c5..2bfeb78 100644 --- a/client/vc_dbus.c +++ b/client/vc_dbus.c @@ -313,17 +313,19 @@ int vc_dbus_close_connection() g_fd_handler = NULL; } - int pid = getpid(); + if (NULL != g_conn_listener) { + int pid = getpid(); - char service_name[64]; - memset(service_name, '\0', 64); - snprintf(service_name, 64, "%s%d", VC_CLIENT_SERVICE_NAME, pid); + char service_name[64]; + memset(service_name, '\0', 64); + snprintf(service_name, 64, "%s%d", VC_CLIENT_SERVICE_NAME, pid); - dbus_bus_release_name(g_conn_listener, service_name, &err); + dbus_bus_release_name(g_conn_listener, service_name, &err); - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Dbus Error (%s)", err.message); - dbus_error_free(&err); + if (dbus_error_is_set(&err)) { + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Dbus Error (%s)", err.message); + dbus_error_free(&err); + } } __vc_dbus_connection_free(); diff --git a/client/vc_mgr_dbus.c b/client/vc_mgr_dbus.c index 4c43f45..d08e9e9 100644 --- a/client/vc_mgr_dbus.c +++ b/client/vc_mgr_dbus.c @@ -712,17 +712,19 @@ int vc_mgr_dbus_close_connection() g_m_fd_handler = NULL; } - int pid = getpid(); + if (NULL != g_m_conn_listener) { + int pid = getpid(); - char service_name[64]; - memset(service_name, '\0', 64); - snprintf(service_name, 64, "%s%d", VC_MANAGER_SERVICE_NAME, pid); + char service_name[64]; + memset(service_name, '\0', 64); + snprintf(service_name, 64, "%s%d", VC_MANAGER_SERVICE_NAME, pid); - dbus_bus_release_name(g_m_conn_listener, service_name, &err); + dbus_bus_release_name(g_m_conn_listener, service_name, &err); - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Dbus Error (%s)", err.message); - dbus_error_free(&err); + if (dbus_error_is_set(&err)) { + SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Dbus Error (%s)", err.message); + dbus_error_free(&err); + } } __vc_mgr_dbus_connection_free(); diff --git a/client/vc_widget_dbus.c b/client/vc_widget_dbus.c index 9d5dbc0..59d7a60 100644 --- a/client/vc_widget_dbus.c +++ b/client/vc_widget_dbus.c @@ -397,17 +397,19 @@ int vc_widget_dbus_close_connection() g_w_fd_handler = NULL; } - int pid = getpid(); + if (NULL != g_w_conn_listener) { + int pid = getpid(); - char service_name[64]; - memset(service_name, '\0', 64); - snprintf(service_name, 64, "%s%d", VC_WIDGET_SERVICE_NAME, pid); + char service_name[64]; + memset(service_name, '\0', 64); + snprintf(service_name, 64, "%s%d", VC_WIDGET_SERVICE_NAME, pid); - dbus_bus_release_name(g_w_conn_listener, service_name, &err); + dbus_bus_release_name(g_w_conn_listener, service_name, &err); - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Dbus Error (%s)", err.message); - dbus_error_free(&err); + if (dbus_error_is_set(&err)) { + SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Dbus Error (%s)", err.message); + dbus_error_free(&err); + } } __vc_mgr_dbus_connection_free(); -- 2.7.4