Modify the memory leak
[platform/core/connectivity/bluetooth-agent.git] / ag-agent / bluetooth-ag-agent.c
old mode 100644 (file)
new mode 100755 (executable)
index a611d94..4696ed0
@@ -2373,7 +2373,6 @@ void __bt_ag_agent_print_at_buffer(char *message, const char *buf)
                }
        }
 
-done:
        /* +XSAT: 11,DISC */
        xsat_ptr =  strstr(s, "11,DISC,");
        if (xsat_ptr) {
@@ -2939,7 +2938,6 @@ static void __bt_ag_agent_method(GDBusConnection *connection,
                GUnixFDList *fd_list;
                GVariant *options = NULL;
                int device_count = 0;
-               GSList *l;
 
                device_count = g_slist_length(active_devices);
 
@@ -3012,11 +3010,7 @@ static void __bt_ag_agent_method(GDBusConnection *connection,
                if (ret)
                        goto fail;
 
-               if (local_addr)
-                       g_free(local_addr);
-
-               local_addr = g_strdup(address);
-               DBG("Address = %s\n", local_addr);
+               DBG("Address = %s\n", address);
                g_dbus_method_invocation_return_value(invocation, NULL);
        } else if (g_strcmp0(method_name, "UnregisterApplication") == 0) {
                gchar *path = NULL;
@@ -3980,13 +3974,15 @@ static void __bt_ag_agent_filter_cb(GDBusConnection *connection,
 {
        FN_START;
        char *path = NULL;
-       GVariant *optional_param;
+       GVariant *optional_param = NULL;
 
        if (strcasecmp(signal_name, "InterfacesAdded") == 0) {
 
                g_variant_get(parameters, "(&o@a{sa{sv}})",
                                                        &path, &optional_param);
                if (!path) {
+                       if (optional_param)
+                               g_variant_unref(optional_param);
                        ERR("Invalid adapter path");
                        return;
                }
@@ -4004,6 +4000,8 @@ static void __bt_ag_agent_filter_cb(GDBusConnection *connection,
        } else if (strcasecmp(signal_name, "InterfacesRemoved") == 0) {
                g_variant_get(parameters, "(&o@as)", &path, &optional_param);
                if (!path) {
+                       if (optional_param)
+                               g_variant_unref(optional_param);
                        ERR("Invalid adapter path");
                        return;
                }
@@ -4018,6 +4016,9 @@ static void __bt_ag_agent_filter_cb(GDBusConnection *connection,
                }
        }
 
+       if (optional_param)
+               g_variant_unref(optional_param);
+
        FN_END;
 }
 
@@ -4137,7 +4138,6 @@ void _bt_ag_agent_check_transport_state(void)
 
        if (transport_state == MEDIA_TRANSPORT_STATE_PLAYING) {
                GDBusProxy *proxy;
-               GVariant *ret;
                GError *err = NULL;
 
                proxy =  g_dbus_proxy_new_sync(ag_dbus_conn,
@@ -4210,7 +4210,7 @@ static void __bt_ag_agent_media_filter_cb(GDBusConnection *connection,
                                        iter, "{sv}", &key, &value_var)) {
                                DBG("key %s", key);
                                if (g_strcmp0(key, "State") == 0) {
-                                       value = g_variant_get_string(
+                                       value = (gchar *)g_variant_get_string(
                                                                value_var,
                                                                NULL);
                                        DBG("value %s", value);
@@ -4233,6 +4233,12 @@ static void __bt_ag_agent_media_filter_cb(GDBusConnection *connection,
                }
        }
 
+       if (dict_param)
+               g_variant_unref(dict_param);
+
+       if (optional_param)
+               g_variant_unref(optional_param);
+
        FN_END;
 }
 #endif
@@ -4332,8 +4338,6 @@ int main(void)
 
        INFO_C("Starting Bluetooth AG agent");
 
-       g_type_init();
-
        ag_features = __bt_ag_agent_get_ag_features();
 
        ag.sdp_features = (uint16_t) ag_features & 0x1F;