u32: prevent memcpy from NULL

Found by Clang static analyzer.

Fixes: 6cdc32df83
Signed-off-by: Peter Wu <peter@lekensteyn.nl>
Signed-off-by: Thomas Haller <thaller@redhat.com>
This commit is contained in:
Peter Wu 2014-06-24 23:13:36 +02:00 committed by Thomas Haller
parent e4c94ea9ed
commit 2ca01afcee

View file

@ -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;