summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2016-06-25 15:31:20 (GMT)
committerThomas Haller <thaller@redhat.com>2016-06-25 15:31:24 (GMT)
commit0ee916bf6bb61e98917081fb6d8273250b34b7cc (patch)
tree93ff13c859b18d5ef354f41b4013c6d15d3644e7
parentfa1076eaac91b9a68be9465a1a92d47f8c7fe23e (diff)
downloadlibnl-0ee916bf6bb61e98917081fb6d8273250b34b7cc.zip
libnl-0ee916bf6bb61e98917081fb6d8273250b34b7cc.tar.gz
libnl-0ee916bf6bb61e98917081fb6d8273250b34b7cc.tar.bz2
xfrm: reuse encap data in xfrmnl_sa_set_encap_tmpl()
Signed-off-by: Thomas Haller <thaller@redhat.com>
-rw-r--r--lib/xfrm/sa.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/lib/xfrm/sa.c b/lib/xfrm/sa.c
index 7e663bb..dc57913 100644
--- a/lib/xfrm/sa.c
+++ b/lib/xfrm/sa.c
@@ -1777,9 +1777,8 @@ int xfrmnl_sa_set_encap_tmpl (struct xfrmnl_sa* sa, unsigned int encap_type, uns
/* Free up the old encap OA */
if (sa->encap->encap_oa)
nl_addr_put(sa->encap->encap_oa);
- free(sa->encap);
- }
- if ((sa->encap = calloc(1, sizeof(*sa->encap))) == NULL)
+ memset(sa->encap, 0, sizeof (*sa->encap));
+ } else if ((sa->encap = calloc(1, sizeof(*sa->encap))) == NULL)
return -1;
/* Save the new info */