Merge changes Ib324dffb,Id4e05e6e into tizen
authortaesub kim <taesub.kim@samsung.com>
Tue, 1 Aug 2017 00:55:21 +0000 (00:55 +0000)
committerGerrit Code Review <gerrit@review.ap-northeast-2.compute.internal>
Tue, 1 Aug 2017 00:55:22 +0000 (00:55 +0000)
* changes:
  Avoid possible memory leak
  Remove dead code and Fix memory leak

1  2 
src/network-state.c

diff --combined src/network-state.c
@@@ -26,6 -26,8 +26,6 @@@
  #include <arpa/inet.h>
  #include <netinet/in.h>
  #include <sys/ioctl.h>
 -#include <ITapiSim.h>
 -#include <TapiUtility.h>
  
  #include "log.h"
  #include "util.h"
@@@ -38,6 -40,7 +38,6 @@@
  #include "network-dpm.h"
  #include "network-monitor.h"
  #include "netsupplicant.h"
 -#include "wifi-tel-intf.h"
  
  #include "generated-code.h"
  /* Define TCP buffer sizes for various networks */
@@@ -319,9 -322,19 +319,9 @@@ static void __netconfig_adjust_tcp_buff
                rmax_size = NET_TCP_BUFFERSIZE_WIFI_RMEM_MAX;
                wmax_size = NET_TCP_BUFFERSIZE_WIFI_WMEM_MAX;
        } else if (netconfig_is_cellular_profile(profile) == TRUE) {
 -              TapiHandle *tapi_handle = NULL;
                int telephony_svctype = 0, telephony_pstype = 0;
  
 -              tapi_handle = (TapiHandle *)netconfig_tel_init();
 -              if (NULL != tapi_handle) {
 -                      tel_get_property_int(tapi_handle,
 -                                      TAPI_PROP_NETWORK_SERVICE_TYPE,
 -                                      &telephony_svctype);
 -                      tel_get_property_int(tapi_handle, TAPI_PROP_NETWORK_PS_TYPE,
 -                                      &telephony_pstype);
 -                      netconfig_tel_deinit();
 -              }
 -
 +              netconfig_get_telephony_network_type(&telephony_svctype, &telephony_pstype);
                DBG("Default cellular %d, %d", telephony_svctype, telephony_pstype);
  
                switch (telephony_pstype) {
@@@ -806,24 -819,30 +806,30 @@@ void netconfig_update_default_profile(c
  
        /* default profile is NULL and new connected profile is NULL */
        if (!profile) {
-               profile = __netconfig_get_default_profile();
+               char *tmp_profile = __netconfig_get_default_profile();
  
-               if (profile && netconfig_is_cellular_profile(profile) &&
-                       !netconfig_is_cellular_internet_profile(profile)) {
+               if (tmp_profile && netconfig_is_cellular_profile(tmp_profile) &&
+                       !netconfig_is_cellular_internet_profile(tmp_profile)) {
                        DBG("not a default cellular profile");
-                       profile = NULL;
+                       g_free(tmp_profile);
+                       tmp_profile = NULL;
                }
  
-               if (!profile) {
+               if (!tmp_profile) {
                        __netconfig_update_default_connection_info();
                        return;
                }
+               netconfig_default_connection_info.profile = g_strdup(tmp_profile);
+               __netconfig_get_default_connection_info(tmp_profile);
+               __netconfig_update_default_connection_info();
+               g_free(tmp_profile);
+               return;
        }
  
        netconfig_default_connection_info.profile = g_strdup(profile);
        __netconfig_get_default_connection_info(profile);
        __netconfig_update_default_connection_info();
  }
  
  void netconfig_update_default(void)
@@@ -877,9 -896,10 +883,10 @@@ char *netconfig_get_ifname(const char *
                        while (g_variant_iter_loop(next, "{sv}", &key1, &variant)) {
                                if (g_strcmp0(key1, "Interface") == 0) {
                                        value = g_variant_get_string(variant, NULL);
-                                       if (ifname)
-                                               g_free(ifname);
                                        ifname = g_strdup(value);
+                                       g_free(key1);
+                                       g_variant_unref(variant);
+                                       break;
                                }
                        }
                }