From 2bde9f3aa465f3befc3c5321bb1efd367c663afb Mon Sep 17 00:00:00 2001 From: Sangchul Lee Date: Thu, 30 Jun 2016 10:29:40 +0900 Subject: [PATCH] Fix memory leak - Used '&s' for string that does not need to free instead of 's' for argument of g_variant_get() in mm_sound_mgr_focus_dbus.c - Added omitted g_error_free() for err variable in mm_sound_dbus.c [Version] Release 0.10.39 [Profile] Common [Issue Type] Memory leak [JIRA] TSAM-5489 Change-Id: I8d936a5729303f099b0a84d4e5d18899df1c5e7a Signed-off-by: Sangchul Lee --- common/mm_sound_dbus.c | 1 + mm_sound_client.c | 3 +-- mm_sound_proxy.c | 34 +++++++++++++++++----------------- packaging/libmm-sound.spec | 2 +- server/mm_sound_mgr_focus_dbus.c | 10 +++++----- server/mm_sound_mgr_ipc_dbus.c | 2 +- 6 files changed, 26 insertions(+), 26 deletions(-) diff --git a/common/mm_sound_dbus.c b/common/mm_sound_dbus.c index 580aac5..3c3350c 100644 --- a/common/mm_sound_dbus.c +++ b/common/mm_sound_dbus.c @@ -538,6 +538,7 @@ int mm_sound_dbus_emit_signal(audio_provider_t provider, audio_event_t event, GV param, &err); if (!dbus_ret) { debug_error ("g_dbus_connection_emit_signal() error (%s)", err->message); + g_error_free(err); return MM_ERROR_SOUND_INTERNAL; } g_dbus_connection_flush_sync(conn, NULL, NULL); diff --git a/mm_sound_client.c b/mm_sound_client.c index 0169718..da077ec 100644 --- a/mm_sound_client.c +++ b/mm_sound_client.c @@ -1067,7 +1067,7 @@ static gboolean _focus_callback_handler(gpointer d) return TRUE; } -static gboolean _focus_watch_callback_handler( gpointer d) +static gboolean _focus_watch_callback_handler(gpointer d) { GPollFD *data = (GPollFD*)d; int count; @@ -1118,7 +1118,6 @@ static gboolean _focus_watch_callback_handler( gpointer d) } #ifdef CONFIG_ENABLE_RETCB - int rett = 0; int tmpfd = -1; int buf = -1; diff --git a/mm_sound_proxy.c b/mm_sound_proxy.c index cd43eb6..9f58de3 100644 --- a/mm_sound_proxy.c +++ b/mm_sound_proxy.c @@ -36,7 +36,7 @@ struct callback_data { static int _notify_subscription(audio_event_t event, uint32_t subs_id, gboolean subscribe) { int ret = MM_ERROR_NONE; - GVariant* params = NULL; + GVariant *params = NULL; const char *event_name = NULL; debug_fenter(); @@ -62,7 +62,7 @@ static int _notify_subscription(audio_event_t event, uint32_t subs_id, gboolean static int _notify_signal_handled(audio_event_t event, uint32_t event_id, uint32_t subs_id, GVariant *signal_params) { int ret = MM_ERROR_NONE; - GVariant* params = NULL; + GVariant *params = NULL; const char *event_name = NULL; debug_fenter(); @@ -209,7 +209,7 @@ int mm_sound_proxy_get_current_connected_device_list(int device_flags, GList** d { int ret = MM_ERROR_NONE; GVariant *result = NULL, *child = NULL; - GVariant *params; + GVariant *params = NULL; GVariantIter iter; mm_sound_device_t* device_item; const gchar *device_name_tmp = NULL, *device_type_tmp = NULL; @@ -408,7 +408,7 @@ int mm_sound_proxy_play_tone(int tone, int repeat, int volume, int volume_config { int ret = MM_ERROR_NONE; int handle = 0; - GVariant* params = NULL, *result = NULL; + GVariant *params = NULL, *result = NULL; gboolean _enable_session = enable_session; if (!codechandle) { @@ -451,7 +451,7 @@ int mm_sound_proxy_play_tone_with_stream_info(int client_pid, int tone, char *st { int ret = MM_ERROR_NONE; int handle = 0; - GVariant* params = NULL, *result = NULL; + GVariant *params = NULL, *result = NULL; debug_fenter(); @@ -494,7 +494,7 @@ int mm_sound_proxy_play_sound(const char* filename, int tone, int repeat, int vo { int ret = MM_ERROR_NONE; int handle = 0; - GVariant* params = NULL, *result = NULL; + GVariant *params = NULL, *result = NULL; gboolean _enable_session = enable_session; if (!filename || !codechandle) { @@ -536,7 +536,7 @@ int mm_sound_proxy_play_sound_with_stream_info(const char* filename, int repeat, { int ret = MM_ERROR_NONE; int handle = 0; - GVariant* params = NULL, *result = NULL; + GVariant *params = NULL, *result = NULL; if (!filename || !codechandle) { debug_error("Param for play is null"); @@ -648,7 +648,7 @@ int mm_sound_proxy_remove_play_sound_end_callback(unsigned subs_id) int mm_sound_proxy_emergent_exit(int exit_pid) { int ret = MM_ERROR_NONE; - GVariant* params = NULL; + GVariant *params = NULL; debug_fenter(); @@ -711,7 +711,7 @@ static GVariant* _get_cookie_variant () for (i = 0; i < COOKIE_SIZE; i++) g_variant_builder_add(&builder, "y", cookie[i]); - free (cookie); + free(cookie); return g_variant_builder_end(&builder); } @@ -745,7 +745,7 @@ int mm_sound_proxy_get_unique_id(int *id) int mm_sound_proxy_register_focus(int id, int instance, const char *stream_type, mm_sound_focus_changed_cb callback, bool is_for_session, void* userdata) { int ret = MM_ERROR_NONE; - GVariant* params = NULL, *result = NULL; + GVariant *params = NULL, *result = NULL; #ifdef SUPPORT_CONTAINER char container[128]; #endif @@ -788,7 +788,7 @@ int mm_sound_proxy_register_focus(int id, int instance, const char *stream_type, int mm_sound_proxy_unregister_focus(int instance, int id, bool is_for_session) { int ret = MM_ERROR_NONE; - GVariant* params = NULL, *result = NULL; + GVariant *params = NULL, *result = NULL; debug_fenter(); @@ -814,7 +814,7 @@ int mm_sound_proxy_unregister_focus(int instance, int id, bool is_for_session) int mm_sound_proxy_set_foucs_reacquisition(int instance, int id, bool reacquisition) { int ret = MM_ERROR_NONE; - GVariant* params = NULL, *result = NULL; + GVariant *params = NULL, *result = NULL; debug_fenter(); @@ -839,7 +839,7 @@ int mm_sound_proxy_set_foucs_reacquisition(int instance, int id, bool reacquisit int mm_sound_proxy_get_acquired_focus_stream_type(int focus_type, char **stream_type, char **additional_info) { int ret = MM_ERROR_NONE; - GVariant* params = NULL, *result = NULL; + GVariant *params = NULL, *result = NULL; debug_fenter(); @@ -864,7 +864,7 @@ int mm_sound_proxy_get_acquired_focus_stream_type(int focus_type, char **stream_ int mm_sound_proxy_acquire_focus(int instance, int id, mm_sound_focus_type_e type, const char *option, bool is_for_session) { int ret = MM_ERROR_NONE; - GVariant* params = NULL, *result = NULL; + GVariant *params = NULL, *result = NULL; debug_fenter(); @@ -889,7 +889,7 @@ int mm_sound_proxy_acquire_focus(int instance, int id, mm_sound_focus_type_e typ int mm_sound_proxy_release_focus(int instance, int id, mm_sound_focus_type_e type, const char *option, bool is_for_session) { int ret = MM_ERROR_NONE; - GVariant* params = NULL, *result = NULL; + GVariant *params = NULL, *result = NULL; debug_fenter(); @@ -914,7 +914,7 @@ int mm_sound_proxy_release_focus(int instance, int id, mm_sound_focus_type_e typ int mm_sound_proxy_set_focus_watch_callback(int instance, int handle, mm_sound_focus_type_e type, mm_sound_focus_changed_watch_cb callback, bool is_for_session, void* userdata) { int ret = MM_ERROR_NONE; - GVariant* params = NULL, *result = NULL; + GVariant *params = NULL, *result = NULL; #ifdef SUPPORT_CONTAINER char container[128]; #endif @@ -954,7 +954,7 @@ int mm_sound_proxy_set_focus_watch_callback(int instance, int handle, mm_sound_f int mm_sound_proxy_unset_focus_watch_callback(int focus_tid, int handle, bool is_for_session) { int ret = MM_ERROR_NONE; - GVariant* params = NULL, *result = NULL; + GVariant *params = NULL, *result = NULL; debug_fenter(); diff --git a/packaging/libmm-sound.spec b/packaging/libmm-sound.spec index f881d58..7375835 100644 --- a/packaging/libmm-sound.spec +++ b/packaging/libmm-sound.spec @@ -1,6 +1,6 @@ Name: libmm-sound Summary: MMSound Package contains client lib and sound_server binary -Version: 0.10.38 +Version: 0.10.39 Release: 0 Group: System/Libraries License: Apache-2.0 diff --git a/server/mm_sound_mgr_focus_dbus.c b/server/mm_sound_mgr_focus_dbus.c index 7a4777c..12ce404 100644 --- a/server/mm_sound_mgr_focus_dbus.c +++ b/server/mm_sound_mgr_focus_dbus.c @@ -304,19 +304,19 @@ static void handle_method_register_focus(GDBusMethodInvocation* invocation) #ifdef SUPPORT_CONTAINER #ifdef USE_SECURITY - g_variant_get(params, "(@ayiisb)", &cookie_data, &container_pid, &handle_id, &stream_type, &is_for_session); + g_variant_get(params, "(@ayii&sb)", &cookie_data, &container_pid, &handle_id, &stream_type, &is_for_session); container = _get_container_from_cookie(cookie_data); ret = __mm_sound_mgr_focus_ipc_register_focus(_get_sender_pid(invocation), handle_id, stream_type, is_for_session, container, container_pid); if (container) free(container); #else /* USE_SECURITY */ - g_variant_get(params, "(siisb)", &container, &container_pid, &handle_id, &stream_type, &is_for_session); + g_variant_get(params, "(&sii&sb)", &container, &container_pid, &handle_id, &stream_type, &is_for_session); ret = __mm_sound_mgr_focus_ipc_register_focus(_get_sender_pid(invocation), handle_id, stream_type, is_for_session, container, container_pid); #endif /* USE_SECURITY */ #else /* SUPPORT_CONTAINER */ - g_variant_get(params, "(iisb)", &pid, &handle_id, &stream_type, &is_for_session); + g_variant_get(params, "(ii&sb)", &pid, &handle_id, &stream_type, &is_for_session); ret = __mm_sound_mgr_focus_ipc_register_focus(_get_sender_pid(invocation), handle_id, stream_type, is_for_session); #endif /* SUPPORT_CONTAINER */ @@ -507,7 +507,7 @@ static void handle_method_watch_focus(GDBusMethodInvocation* invocation) if (container) free(container); #else /* USE_SECURITY */ - g_variant_get(params, "(siiib)", &container, &container_pid, &handle_id, &focus_type, &is_for_session); + g_variant_get(params, "(&siiib)", &container, &container_pid, &handle_id, &focus_type, &is_for_session); ret = __mm_sound_mgr_focus_ipc_watch_focus(_get_sender_pid(invocation), handle_id, focus_type, is_for_session, container, container_pid); #endif /* USE_SECURITY */ @@ -760,7 +760,7 @@ int MMSoundMgrFocusDbusInit(void) { debug_enter(); - introspection_data = g_dbus_node_info_new_for_xml (introspection_xml, NULL); + introspection_data = g_dbus_node_info_new_for_xml(introspection_xml, NULL); if (!introspection_data) return MM_ERROR_SOUND_INTERNAL; diff --git a/server/mm_sound_mgr_ipc_dbus.c b/server/mm_sound_mgr_ipc_dbus.c index 6b812d0..d48aff7 100644 --- a/server/mm_sound_mgr_ipc_dbus.c +++ b/server/mm_sound_mgr_ipc_dbus.c @@ -269,7 +269,7 @@ static void handle_method_test(GDBusMethodInvocation* invocation) { int ret = MM_ERROR_NONE; int val = 0, val2 = 0; - GVariant* params = NULL; + GVariant *params = NULL; debug_fenter(); -- 2.7.4