We do actually want to check for NULL pointers, not to prevent g_strcmp0
from crashing, but because we want to compare the 2 pointers when we've
been given one and the network we're looking at has a pointer too.
For example if we call find_network() without an address, it basically
means "find a network with an SSID, and with _any_ address". But then
we're going to compare a NULL pointer with the network's address and
that's gonna be -1. As a consequence, we'll skip this network while
we shouldnt.
if (tmp_ssid && memcmp(ssid, tmp_ssid, tmp_ssid_size))
continue;
- if (g_strcmp0(security, tmp_security) != 0)
+ if (security && tmp_security &&
+ g_strcmp0(security, tmp_security) != 0)
continue;
- if (g_strcmp0(mode, tmp_mode) != 0)
+ if (mode && tmp_mode && g_strcmp0(mode, tmp_mode) != 0)
continue;
- if (g_strcmp0(address, tmp_address) != 0)
+ if (address && tmp_address &&
+ g_strcmp0(address, tmp_address) != 0)
continue;
return connman_network_ref(value);