Check if it's null after g_try_malloc0 18/243918/1 submit/tizen/20200911.080000
authorCheoleun Moon <chleun.moon@samsung.com>
Fri, 11 Sep 2020 07:25:20 +0000 (16:25 +0900)
committerCheoleun Moon <chleun.moon@samsung.com>
Fri, 11 Sep 2020 07:25:25 +0000 (16:25 +0900)
Change-Id: I30ad68d1fb651159c91af1092a6b55656ebb6b55

tests/unittest/wifi-aware-unittest-util.cpp

index b7342fb..0b0fa3b 100644 (file)
@@ -189,6 +189,9 @@ wifi_aware_session_h __create_dummy_session(wifi_aware_session_type_e type, bool
 {
        __wifi_aware_session_s *session =
                (__wifi_aware_session_s *)g_try_malloc0(sizeof(__wifi_aware_session_s));
+       if (session == NULL)
+               return NULL;
+
        session->pub_sub_id = is_created ? 1 : 0;
        session->session_type = type;
        return session;
@@ -207,6 +210,9 @@ void __set_subscribe_config(wifi_aware_session_h session, wifi_aware_subscribe_h
 wifi_aware_peer_h __create_dummy_peer()
 {
        __wifi_aware_peer_s *peer = (__wifi_aware_peer_s *)g_try_malloc0(sizeof(__wifi_aware_peer_s));
+       if (peer == NULL)
+               return NULL;
+
        peer->id = 1;
        memset(peer->mac, sizeof(unsigned char), MAC_ADDR_LEN);
        return peer;
@@ -221,6 +227,9 @@ wifi_aware_data_path_h __create_dummy_data_path(wifi_aware_session_h session, wi
 {
        __wifi_aware_data_path_s *data_path =
                (__wifi_aware_data_path_s *)g_try_malloc0(sizeof(__wifi_aware_data_path_s));
+       if (data_path == NULL)
+               return NULL;
+
        data_path->ndp_id = 1;
        data_path->port = DATA_PATH_PEER_PORT;
        snprintf(data_path->iface_name, IFNAMSIZ, "ndp0");