init_route() can allocate memory in netlist, but fail in many more ways than just fail to allocate. Thus, always check and clean up netlist if needed, instead of just when init_route() succeeds.
This fix is for release/2.3 only. The master branch uses a gc to clean up the netlist, and needs a different patch for a similar problem. Found using coverity. Signed-off-by: Steffan Karger <stef...@karger.me> --- src/openvpn/route.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/openvpn/route.c b/src/openvpn/route.c index bb998cb..a3d4b71 100644 --- a/src/openvpn/route.c +++ b/src/openvpn/route.c @@ -648,7 +648,7 @@ init_route_list (struct route_list *rl, bool warned = false; for (i = 0; i < opt->n; ++i) { - struct addrinfo* netlist; + struct addrinfo* netlist = NULL; struct route_ipv4 r; if (!init_route (&r, @@ -675,8 +675,9 @@ init_route_list (struct route_list *rl, } } } - freeaddrinfo(netlist); } + if (netlist) + freeaddrinfo(netlist); } rl->n = j; } -- 2.5.0