From 36820c0aea11a2a722b6b7ed1a947a0fe44f9cb9 Mon Sep 17 00:00:00 2001 From: Jaechul Lee Date: Fri, 24 Jul 2020 16:18:26 +0900 Subject: [PATCH] Adds g_variant_unref when param variable is not used param variable that is on a floating state should be deallocated if it is not used. Change-Id: I25da4f7f63a588f5190f3b7741bddb67304c6c78 Signed-off-by: Jaechul Lee --- src/tone_player.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/tone_player.c b/src/tone_player.c index d525a75..f524845 100755 --- a/src/tone_player.c +++ b/src/tone_player.c @@ -61,14 +61,18 @@ static int __dbus_method_call(const char *method, GVariant *param, GVariant **re GDBusConnection *conn = NULL; GVariant * _reply = NULL; GError *err = NULL; + int ret; if (!method || !param) { LOGE("invalid parameter"); - return TONE_PLAYER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE + ret = TONE_PLAYER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE + goto error; } - if (!(conn = __get_dbus_connection())) - return TONE_PLAYER_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE + if (!(conn = __get_dbus_connection())) { + ret = TONE_PLAYER_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE + goto error; + } _reply = g_dbus_connection_call_sync(conn, PA_BUS_NAME, PA_TONE_PLAYER_OBJECT_PATH, @@ -78,8 +82,6 @@ static int __dbus_method_call(const char *method, GVariant *param, GVariant **re g_object_unref(conn); if (!_reply) { - int ret; - LOGE("g_dbus_connection_call_sync() method(%s), err-msg(%s)", method, err->message); ret = _convert_dbus_error(err->message); g_error_free(err); @@ -92,6 +94,12 @@ static int __dbus_method_call(const char *method, GVariant *param, GVariant **re g_variant_unref(_reply); return TONE_PLAYER_ERROR_NONE; + +error: + if (param) + g_variant_unref(param); + + return ret; } -- 2.34.1