}
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) {
{
size_t i;
#ifdef RT_FREE_ROUTE_TABLE
+ struct interface *ifp;
struct rt *rt;
#endif
struct dhcp_opt *opt;
/* 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);