From 97d2460fabaabffce0d224bdd24c0bdfee57dbf1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Lo=C3=AFc=20Touraine?= Date: Wed, 29 Aug 2012 12:14:01 +0200 Subject: [PATCH] route_clone : fix segmentation fault using nl_cache_subset to filter routes reset the nb nhops to 0 (dst->rt_nr_nh = 0) before setting the dst->nhops from the src->nhops --- lib/route/route_obj.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/route/route_obj.c b/lib/route/route_obj.c index 40a157e..62669a9 100644 --- a/lib/route/route_obj.c +++ b/lib/route/route_obj.c @@ -110,6 +110,9 @@ static int route_clone(struct nl_object *_dst, struct nl_object *_src) if (!(dst->rt_pref_src = nl_addr_clone(src->rt_pref_src))) return -NLE_NOMEM; + /* Will be inc'ed again while adding the nexthops of the source */ + dst->rt_nr_nh = 0; + nl_init_list_head(&dst->rt_nexthops); nl_list_for_each_entry(nh, &src->rt_nexthops, rtnh_list) { new = rtnl_route_nh_clone(nh); -- 2.40.0