diff options
| author | Donald Sharp <sharpd@cumulusnetworks.com> | 2015-11-21 16:47:32 -0800 |
|---|---|---|
| committer | Donald Sharp <sharpd@cumulusnetworks.com> | 2015-11-23 13:31:04 -0800 |
| commit | 3a7c85d1dedb672ba19ea8958f18f5f7d0fe2321 (patch) | |
| tree | e9e41dd9996a9b5e98db00601eef2159d8faeb54 /lib/distribute.c | |
| parent | 1a1f4efab365954c7b0ab56e974c2d707c0923c5 (diff) | |
lib: Fixup of NULL calls to XSTRDUP
There are a few situations where XSTRDUP can be called with a NULL
This fix makes this impossible to happen
Ticket: CM-8039
Reviewed-by: CCR-3849
Testing: Rip no longer crashes
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Diffstat (limited to 'lib/distribute.c')
| -rw-r--r-- | lib/distribute.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/distribute.c b/lib/distribute.c index 525177e17b..fdd028d813 100644 --- a/lib/distribute.c +++ b/lib/distribute.c @@ -69,10 +69,12 @@ distribute_lookup (const char *ifname) struct distribute *dist; /* temporary reference */ - key.ifname = XSTRDUP(MTYPE_DISTRIBUTE_IFNAME, ifname); + key.ifname = (ifname) ? XSTRDUP(MTYPE_DISTRIBUTE_IFNAME, ifname) : NULL; dist = hash_lookup (disthash, &key); - XFREE(MTYPE_DISTRIBUTE_IFNAME, key.ifname); + + if (key.ifname) + XFREE(MTYPE_DISTRIBUTE_IFNAME, key.ifname); return dist; } @@ -110,11 +112,13 @@ distribute_get (const char *ifname) struct distribute *ret; /* temporary reference */ - key.ifname = XSTRDUP(MTYPE_DISTRIBUTE_IFNAME, ifname); + key.ifname = (ifname) ? XSTRDUP(MTYPE_DISTRIBUTE_IFNAME, ifname) : NULL; ret = hash_get (disthash, &key, (void * (*) (void *))distribute_hash_alloc); - XFREE(MTYPE_DISTRIBUTE_IFNAME, key.ifname); + if (key.ifname) + XFREE(MTYPE_DISTRIBUTE_IFNAME, key.ifname); + return ret; } |
