summaryrefslogtreecommitdiff
path: root/lib/if_rmap.c
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2015-11-21 16:47:32 -0800
committerDonald Sharp <sharpd@cumulusnetworks.com>2015-11-23 13:31:04 -0800
commit3a7c85d1dedb672ba19ea8958f18f5f7d0fe2321 (patch)
treee9e41dd9996a9b5e98db00601eef2159d8faeb54 /lib/if_rmap.c
parent1a1f4efab365954c7b0ab56e974c2d707c0923c5 (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/if_rmap.c')
-rw-r--r--lib/if_rmap.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/if_rmap.c b/lib/if_rmap.c
index 26a6d8c55b..f2d76c69d6 100644
--- a/lib/if_rmap.c
+++ b/lib/if_rmap.c
@@ -64,11 +64,13 @@ if_rmap_lookup (const char *ifname)
struct if_rmap *if_rmap;
/* temporary copy */
- key.ifname = XSTRDUP (MTYPE_IF_RMAP_NAME, ifname);
+ key.ifname = (ifname) ? XSTRDUP (MTYPE_IF_RMAP_NAME, ifname) : NULL;
if_rmap = hash_lookup (ifrmaphash, &key);
- XFREE(MTYPE_IF_RMAP_NAME, key.ifname);
+ if (key.ifname)
+ XFREE(MTYPE_IF_RMAP_NAME, key.ifname);
+
return if_rmap;
}
@@ -103,9 +105,10 @@ if_rmap_get (const char *ifname)
struct if_rmap *ret;
/* temporary copy */
- key.ifname = XSTRDUP (MTYPE_IF_RMAP_NAME, ifname);
+ key.ifname = (ifname) ? XSTRDUP (MTYPE_IF_RMAP_NAME, ifname) : NULL;
ret = hash_get (ifrmaphash, &key, if_rmap_hash_alloc);
+
if (key.ifname)
XFREE(MTYPE_IF_RMAP_NAME, key.ifname);