Fix memory leaks and dereference without null check 35/259635/1 accepted/tizen/unified/20210616.132525 submit/tizen/20210615.081101
authorJaehyun Kim <jeik01.kim@samsung.com>
Thu, 10 Jun 2021 09:20:00 +0000 (18:20 +0900)
committerJaehyun Kim <jeik01.kim@samsung.com>
Thu, 10 Jun 2021 09:20:00 +0000 (18:20 +0900)
Change-Id: I7accd1386302c26e5bdfa8aee224fe60defc50af
Signed-off-by: Jaehyun Kim <jeik01.kim@samsung.com>
plugins/wifi.c
src/service.c
vpn/plugins/openvpn.c
vpn/vpn-provider.c

index 6a886d5..4257a5d 100755 (executable)
@@ -2643,6 +2643,9 @@ static int get_latest_connections(int max_ssids,
                                g_sequence_free(latest_list);
                                g_key_file_free(keyfile);
                                g_free(ssid);
+#if defined TIZEN_EXT
+                               g_strfreev(services);
+#endif
                                return -ENOMEM;
                        }
 
@@ -5244,6 +5247,8 @@ static void network_changed(GSupplicantNetwork *network, const char *property)
                        need_save = connman_device_set_last_connected_ident(wifi->device, service_ident);
                        if (need_save)
                                connman_device_save_last_connected(wifi->device);
+
+                       g_free(service_ident);
                }
 
                connman_network_set_last_connected_bssid(connman_network,
index e4dbc32..2b69a0b 100755 (executable)
@@ -1834,6 +1834,7 @@ static void __connman_manage_saved_profiles()
                if (!entry) {
                        g_sequence_free(profile_list);
                        g_key_file_free(keyfile);
+                       g_strfreev(services);
                        return;
                }
 
@@ -1857,6 +1858,7 @@ static void __connman_manage_saved_profiles()
        }
 
        g_sequence_free(profile_list);
+       g_strfreev(services);
 }
 #endif
 
index 9e8cceb..ef0bf78 100755 (executable)
@@ -152,8 +152,15 @@ static struct nameserver_entry *ov_append_dns_entries(const char *key,
                                options[2]) {
 
                entry = g_try_new(struct nameserver_entry, 1);
+#if defined TIZEN_EXT
+               if (!entry) {
+                       g_strfreev(options);
+                       return NULL;
+               }
+#else
                if (!entry)
                        return NULL;
+#endif
 
                entry->nameserver = g_strdup(options[2]);
                entry->id = atoi(key + 15); /* foreign_option_XXX */
index 0e01ca2..8d2836e 100755 (executable)
@@ -2746,6 +2746,10 @@ void vpn_provider_set_data(struct vpn_provider *provider, void *data)
 
 void *vpn_provider_get_plugin_data(struct vpn_provider *provider)
 {
+#if defined TIZEN_EXT
+       if (!provider)
+               return NULL;
+#endif
        return provider->plugin_data;
 }