changeset 4149:fce599d14e9a draft

Free any allocated routes if we failed to allocate some.
author Roy Marples <roy@marples.name>
date Thu, 05 Oct 2017 07:35:16 +0100
parents 7f3db9498fa8
children 4d9679283c1e
files src/route.c
diffstat 1 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/route.c	Wed Oct 04 16:07:49 2017 +0100
+++ b/src/route.c	Thu Oct 05 07:35:16 2017 +0100
@@ -476,13 +476,13 @@
 #ifdef INET
 	case AF_INET:
 		if (!inet_getroutes(ctx, &routes))
-			return;
+			goto getfail;
 		break;
 #endif
 #ifdef INET6
 	case AF_INET6:
 		if (!inet6_getroutes(ctx, &routes))
-			return;
+			goto getfail;
 		break;
 #endif
 	}
@@ -520,5 +520,7 @@
 
 	rt_headclear(&ctx->routes, af);
 	TAILQ_CONCAT(&ctx->routes, &added, rt_next);
+
+getfail:
 	rt_headclear(&routes, AF_UNSPEC);
 }