make osmo_cni_peer_id_cmp() NULL safe

Related: coverity CID#210172
Change-Id: I400b23ac3f0eb68d5e4c757ea02d130fbe12f80b
This commit is contained in:
Neels Hofmeyr 2020-05-04 17:30:44 +02:00
parent a450a85956
commit 3e79a38440
1 changed files with 6 additions and 0 deletions

View File

@ -154,6 +154,12 @@ int osmo_cni_peer_id_set_str(struct osmo_cni_peer_id *cni_peer_id, enum osmo_cni
int osmo_cni_peer_id_cmp(const struct osmo_cni_peer_id *a, const struct osmo_cni_peer_id *b)
{
if (a == b)
return 0;
if (!a)
return -1;
if (!b)
return 1;
if (a->type != b->type)
return OSMO_CMP(a->type, b->type);
switch (a->type) {