]> git.ipfire.org Git - thirdparty/libnl.git/commitdiff
u32: prevent memcpy from NULL
authorPeter Wu <peter@lekensteyn.nl>
Tue, 24 Jun 2014 21:13:36 +0000 (23:13 +0200)
committerThomas Haller <thaller@redhat.com>
Wed, 25 Jun 2014 07:16:48 +0000 (09:16 +0200)
Found by Clang static analyzer.

Fixes: 6cdc32df831a273007af7d24a3f75cd06e0ae738
Signed-off-by: Peter Wu <peter@lekensteyn.nl>
Signed-off-by: Thomas Haller <thaller@redhat.com>
lib/route/cls/u32.c

index e91c39a366efa50c4cc4b5cce3664014f69cdba4..0a4e83cf30834af2649b0f7855c7d70da0c0c522 100644 (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;