Add Null Check to avoid potential crash
[platform/core/api/connection.git] / src / libnetwork.c
old mode 100644 (file)
new mode 100755 (executable)
index 53971c3..0c826d9
@@ -482,6 +482,9 @@ bool _connection_libnet_check_profile_validity(connection_profile_h profile)
        GSList *list;
        int i = 0;
 
+       if (profile == NULL)
+               return false;
+
        for (list = prof_handle_list; list; list = list->next)
                if (profile == list->data) return true;
 
@@ -552,6 +555,11 @@ int _connection_libnet_get_ethernet_state(connection_ethernet_state_e* state)
                return CONNECTION_ERROR_PERMISSION_DENIED;
        }
 
+       if (ethernet_profiles.count == 0) {
+               state = CONNECTION_ETHERNET_STATE_DEACTIVATED;
+               return true;
+       }
+
        switch (ethernet_profiles.profiles->ProfileState) {
        case NET_STATE_TYPE_ONLINE:
        case NET_STATE_TYPE_READY: