Restrict lifetime of $router_name and $transport_name. Bug 308.
[exim.git] / src / src / route.c
index f8bacf11be7f2acc90f9b67708927034a15dba70..2fee382719bdb4a28dae74613867f6dff51fc453 100644 (file)
@@ -1512,7 +1512,6 @@ for (r = (addr->start_router == NULL)? routers : addr->start_router;
   int rc;
 
   DEBUG(D_route) debug_printf("--------> %s router <--------\n", r->name);
-  router_name = r->name;
 
   /* Reset any search error message from the previous router. */
 
@@ -1634,6 +1633,7 @@ for (r = (addr->start_router == NULL)? routers : addr->start_router;
   /* Set the expansion variables now that we have the affixes and the case of
   the local part sorted. */
 
+  router_name = r->name;
   deliver_set_expansions(addr);
 
   /* For convenience, the pre-router checks are in a separate function, which
@@ -1641,6 +1641,7 @@ for (r = (addr->start_router == NULL)? routers : addr->start_router;
 
   if ((rc = check_router_conditions(r, addr, verify, &pw, &error)) != OK)
     {
+    router_name = NULL;
     if (rc == SKIP) continue;
     addr->message = error;
     yield = rc;
@@ -1679,6 +1680,7 @@ for (r = (addr->start_router == NULL)? routers : addr->start_router;
           {
           DEBUG(D_route)
             debug_printf("\"more\"=false: skipping remaining routers\n");
+         router_name = NULL;
           r = NULL;
           break;
           }
@@ -1722,6 +1724,8 @@ for (r = (addr->start_router == NULL)? routers : addr->start_router;
   yield = (r->info->code)(r, addr, pw, verify, paddr_local, paddr_remote,
     addr_new, addr_succeed);
 
+  router_name = NULL;
+
   if (yield == FAIL)
     {
     HDEBUG(D_route) debug_printf("%s router forced address failure\n", r->name);
@@ -1968,6 +1972,7 @@ if (yield == DEFER) {
 }
 
 deliver_set_expansions(NULL);
+router_name = NULL;
 disable_logging = FALSE;
 return yield;
 }