diff options
author | Peter Wu <peter@lekensteyn.nl> | 2014-06-24 21:13:36 (GMT) |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2014-06-25 07:16:48 (GMT) |
commit | 2ca01afceeb224d3a5d6f6a1d0eff741337da05d (patch) | |
tree | cdb9da0fd31657255730497a8f438e51e8ebcfec | |
parent | e4c94ea9ed1c391db4619c04512666bc099b3aba (diff) | |
download | libnl-2ca01afceeb224d3a5d6f6a1d0eff741337da05d.zip libnl-2ca01afceeb224d3a5d6f6a1d0eff741337da05d.tar.gz libnl-2ca01afceeb224d3a5d6f6a1d0eff741337da05d.tar.bz2 |
u32: prevent memcpy from NULL
Found by Clang static analyzer.
Fixes: 6cdc32df831a273007af7d24a3f75cd06e0ae738
Signed-off-by: Peter Wu <peter@lekensteyn.nl>
Signed-off-by: Thomas Haller <thaller@redhat.com>
-rw-r--r-- | lib/route/cls/u32.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/route/cls/u32.c b/lib/route/cls/u32.c index e91c39a..0a4e83c 100644 --- a/lib/route/cls/u32.c +++ b/lib/route/cls/u32.c @@ -170,9 +170,12 @@ static int u32_clone(void *_dst, void *_src) !(dst->cu_selector = nl_data_clone(src->cu_selector))) return -NLE_NOMEM; - if (src->cu_act && !(dst->cu_act = rtnl_act_alloc())) - return -NLE_NOMEM; - memcpy(dst->cu_act, src->cu_act, sizeof(struct rtnl_act)); + if (src->cu_act) { + if (!(dst->cu_act = rtnl_act_alloc())) + return -NLE_NOMEM; + + memcpy(dst->cu_act, src->cu_act, sizeof(struct rtnl_act)); + } if (src->cu_police && !(dst->cu_police = nl_data_clone(src->cu_police))) return -NLE_NOMEM; |