Adds g_variant_unref when param variable is not used 62/239362/4 accepted/tizen_6.0_unified accepted/tizen_6.0_unified_hotfix tizen_6.0 tizen_6.0_hotfix accepted/tizen/6.0/unified/20201030.122810 accepted/tizen/6.0/unified/hotfix/20201103.005059 accepted/tizen/6.0/unified/hotfix/20201103.052548 accepted/tizen/6.5/unified/20211028.101433 accepted/tizen/unified/20200810.123023 submit/tizen/20200810.051914 submit/tizen_6.0/20201029.205102 submit/tizen_6.0_hotfix/20201102.192502 submit/tizen_6.0_hotfix/20201103.114802 submit/tizen_6.5/20211028.161801 tizen_6.0.m2_release tizen_6.5.m2_release
authorJaechul Lee <jcsing.lee@samsung.com>
Fri, 24 Jul 2020 07:18:26 +0000 (16:18 +0900)
committerJaechul Lee <jcsing.lee@samsung.com>
Mon, 10 Aug 2020 01:44:32 +0000 (10:44 +0900)
param variable that is on a floating state should be deallocated if it is
not used.

Change-Id: I25da4f7f63a588f5190f3b7741bddb67304c6c78
Signed-off-by: Jaechul Lee <jcsing.lee@samsung.com>
src/tone_player.c

index d525a75..f524845 100755 (executable)
@@ -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;
 }