Fix a memory leak
[platform/core/connectivity/stc-manager.git] / plugin / tether / stc-plugin-tether.c
old mode 100644 (file)
new mode 100755 (executable)
index 2641509..f1278f9
@@ -181,16 +181,16 @@ static void _mobileap_signal_cb(GDBusConnection *conn,
 
        STC_LOGI("%s interface(%s)", sig, interface);
 
-       sta = (tether_sta_info_s *)g_malloc0(sizeof(tether_sta_info_s));
-       if (sta == NULL) {
-               STC_LOGE("g_malloc0 failed");
-               return;
-       }
-
        g_variant_get(param, "(susssu)", &state, &type, &ip, &mac, &hostname, &tm);
        STC_LOGI("%s: ip(%s) mac(%s) name(%s) tm(%d)", state, ip, mac, hostname, tm);
 
        if (!g_strcmp0(state, "DhcpConnected")) {
+               sta = (tether_sta_info_s *)g_malloc0(sizeof(tether_sta_info_s));
+               if (sta == NULL) {
+                       STC_LOGE("g_malloc0 failed");
+                       return;
+               }
+
                g_strlcpy(sta->ip, ip, INET_ADDRSTRLEN);
                g_strlcpy(sta->mac, mac, STATION_MAC_STR_LEN);
                g_strlcpy(sta->name, hostname, STATION_STR_HOSTNAME_LEN);