diff --git a/usr.bin/rdist/gram.y b/usr.bin/rdist/gram.y index 22d0ee87ac2f..09f6f68e8418 100644 --- a/usr.bin/rdist/gram.y +++ b/usr.bin/rdist/gram.y @@ -383,11 +383,11 @@ insert(label, files, hosts, subcmds) struct subcmd *subcmds; { register struct cmd *c, *prev, *nc; - register struct namelist *h; + register struct namelist *h, *next_h; files = expand(files, E_VARS|E_SHELL); hosts = expand(hosts, E_ALL); - for (h = hosts; h != NULL; free(h), h = h->n_next) { + for (h = hosts; h != NULL; next_h = h->n_next, free(h), h = next_h) { /* * Search command list for an update to the same host. */