diff options
| -rw-r--r-- | src/dhcpcd.c | 2 | ||||
| -rw-r--r-- | src/if-options.c | 10 |
2 files changed, 8 insertions, 4 deletions
diff --git a/src/dhcpcd.c b/src/dhcpcd.c index ac498a62..5b64abf4 100644 --- a/src/dhcpcd.c +++ b/src/dhcpcd.c @@ -2125,13 +2125,13 @@ exit1: } free(ctx.ifaces); } + free_options(&ctx, ifo); #ifdef HAVE_OPEN_MEMSTREAM if (ctx.script_fp) fclose(ctx.script_fp); #endif free(ctx.script_buf); free(ctx.script_env); - free_options(&ctx, ifo); rt_dispose(&ctx); free(ctx.duid); if (ctx.link_fd != -1) { diff --git a/src/if-options.c b/src/if-options.c index 04e519ee..19337e04 100644 --- a/src/if-options.c +++ b/src/if-options.c @@ -2612,6 +2612,7 @@ free_options(struct dhcpcd_ctx *ctx, struct if_options *ifo) { size_t i; #ifdef RT_FREE_ROUTE_TABLE + struct interface *ifp; struct rt *rt; #endif struct dhcp_opt *opt; @@ -2640,9 +2641,12 @@ free_options(struct dhcpcd_ctx *ctx, struct if_options *ifo) /* Stupidly, we don't know the interface when creating the options. * As such, make sure each route has one so they can goto the * free list. */ - RB_TREE_FOREACH(rt, &ifo->routes) { - if (rt->rt_ifp == NULL) - rt->rt_ifp = TAILQ_FIRST(ctx->ifaces); + ifp = ctx->ifaces != NULL ? TAILQ_FIRST(ctx->ifaces) : NULL; + if (ifp != NULL) { + RB_TREE_FOREACH(rt, &ifo->routes) { + if (rt->rt_ifp == NULL) + rt->rt_ifp = ifp; + } } #endif rt_headclear0(ctx, &ifo->routes, AF_UNSPEC); |
