Add NULL check before g_strlcpy operation in ua_user_remove_device() accepted/tizen/unified/20191008.101535 submit/tizen/20191008.005850
authorNishant Chaprana <n.chaprana@samsung.com>
Mon, 7 Oct 2019 12:35:44 +0000 (18:05 +0530)
committersaerome.kim <saerome.kim@samsung.com>
Tue, 8 Oct 2019 00:55:15 +0000 (09:55 +0900)
The ua_user_remove_device() returns INVALID_PARAMETER error
when both device_id and mac are NULL.
However when device_id is only NULL and mac is not NULL
then Glib warning will be generated.

Change-Id: I26a21db9659866d3e1a2e6ded9722e9897e958d9
Signed-off-by: Nishant Chaprana <n.chaprana@samsung.com>
src/user-awareness-users.c

index 53d08a3010a6831caadf0df2edc6c3a94fe38b9b..0e4ea15e92df856c6b7f86d8339d0baf7c7b9931 100644 (file)
@@ -894,7 +894,8 @@ int ua_user_remove_device(ua_user_h user_handle, ua_device_h device_handle)
        if (device->mac)
                g_strlcpy(uam_device.mac, device->mac, UAM_MAC_ADDRESS_STRING_LEN);
 
-       g_strlcpy(uam_device.device_id, device->device_id, UA_MOBILE_ID_STRING_LEN);
+       if (device->device_id)
+               g_strlcpy(uam_device.device_id, device->device_id, UA_MOBILE_ID_STRING_LEN);
 
        if (device->ipv4)
                g_strlcpy(uam_device.ipv4_addr, device->ipv4, UA_IPV4_ADDRESS_STRING_LEN);