From: Roy Marples Date: Thu, 5 Oct 2017 06:35:16 +0000 (+0100) Subject: Free any allocated routes if we failed to allocate some. X-Git-Tag: v7.0.0-rc3~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7a4468b8da89ed0da2fe3c4d37b11121db3f4baa;p=thirdparty%2Fdhcpcd.git Free any allocated routes if we failed to allocate some. --- diff --git a/src/route.c b/src/route.c index 29ca47eb..fdffaeb9 100644 --- a/src/route.c +++ b/src/route.c @@ -476,13 +476,13 @@ rt_build(struct dhcpcd_ctx *ctx, int af) #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_build(struct dhcpcd_ctx *ctx, int af) rt_headclear(&ctx->routes, af); TAILQ_CONCAT(&ctx->routes, &added, rt_next); + +getfail: rt_headclear(&routes, AF_UNSPEC); }