]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Free any allocated routes if we failed to allocate some.
authorRoy Marples <roy@marples.name>
Thu, 5 Oct 2017 06:35:16 +0000 (07:35 +0100)
committerRoy Marples <roy@marples.name>
Thu, 5 Oct 2017 06:35:16 +0000 (07:35 +0100)
src/route.c

index 29ca47ebc98be8bf206dc69e7a7bf5223d04a028..fdffaeb9ab8bf01644a492900ff62e2d4e3cbd5b 100644 (file)
@@ -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);
 }