Fix memory leak 44/228544/1 submit/tizen/20200406.044722
authorINSUN PYO <insun.pyo@samsung.com>
Mon, 23 Mar 2020 23:39:56 +0000 (08:39 +0900)
committerINSUN PYO <insun.pyo@samsung.com>
Mon, 23 Mar 2020 23:39:56 +0000 (08:39 +0900)
Change-Id: I6f008a1efa4ccf9607ce5699f4a1cf5045e64c22

plugin/wpasupplicant/ctrl_iface_dbus/wfd-plugin-wpasupplicant.c

index 9ae8403..7ffd921 100644 (file)
@@ -1738,7 +1738,8 @@ int ws_get_advertise_service(const char *peer_path, GList **asp_services)
        GDBusConnection *g_dbus = NULL;
        GVariant *param = NULL;
        GVariant *reply = NULL;
-       GVariant *temp = NULL;
+       GVariant *temp1 = NULL;
+       GVariant *temp2 = NULL;
        GError *error = NULL;
        GVariantIter *iter = NULL;
        wfd_oem_advertise_service_s *service;
@@ -1795,14 +1796,16 @@ int ws_get_advertise_service(const char *peer_path, GList **asp_services)
                 * So, you need to remove tuple out side of variant and
                 * variant out side of byte array
                 * */
-               temp = g_variant_get_child_value(reply, 0);
-               temp = g_variant_get_child_value(temp, 0);
-               g_variant_get(temp, "ay", &iter);
+               temp1 = g_variant_get_child_value(reply, 0);
+               temp2 = g_variant_get_child_value(temp1, 0);
+               g_variant_get(temp2, "ay", &iter);
                if (iter == NULL) {
                        g_variant_unref(reply);
                        WDP_LOGE("Failed to get iterator");
                        return -1;
                }
+               g_variant_unref(tmp2);
+               g_variant_unref(tmp1);
 
                while (1) {
                        /* 4byte advertisement ID, 2 byte config method, 1byte length */
@@ -1886,7 +1889,8 @@ int ws_get_advertise_asp_service(const char *peer_path, GList **asp_services)
        GDBusConnection *g_dbus = NULL;
        GVariant *param = NULL;
        GVariant *reply = NULL;
-       GVariant *temp = NULL;
+       GVariant *temp1 = NULL;
+       GVariant *temp2 = NULL;
        GError *error = NULL;
        GVariantIter *iter = NULL;
        wfd_oem_advertise_service_s *service;
@@ -1945,14 +1949,16 @@ int ws_get_advertise_asp_service(const char *peer_path, GList **asp_services)
                 * So, you need to remove tuple out side of variant and
                 * variant out side of byte array
                 * */
-               temp = g_variant_get_child_value(reply, 0);
-               temp = g_variant_get_child_value(temp, 0);
-               g_variant_get(temp, "ay", &iter);
+               temp1 = g_variant_get_child_value(reply, 0);
+               temp2 = g_variant_get_child_value(temp1, 0);
+               g_variant_get(temp2, "ay", &iter);
                if (iter == NULL) {
                        g_variant_unref(reply);
                        WDP_LOGE("Failed to get iterator");
                        return -1;
                }
+               g_variant_unref(temp2);
+               g_variant_unref(temp1);
 
                while (1) {
                        /* 4byte advertisement ID, 2 byte config method, 1byte length */