diff --git a/src/frontend/breakp2.c b/src/frontend/breakp2.c index 83fc05831..ef9b8d21a 100644 --- a/src/frontend/breakp2.c +++ b/src/frontend/breakp2.c @@ -49,7 +49,7 @@ com_save2(wordlist *wl, char *name) void settrace(wordlist *wl, int what, char *name) { - struct dbcomm *d, *td; + struct dbcomm *d, *last; char *s; if (!ft_curckt) { @@ -57,6 +57,12 @@ settrace(wordlist *wl, int what, char *name) return; } + if (dbs) + for (last = dbs; last->db_next; last = last->db_next) + ; + else + last = NULL; + while (wl) { s = cp_unquote(wl->wl_word); d = TMALLOC(struct dbcomm, 1); @@ -96,13 +102,12 @@ settrace(wordlist *wl, int what, char *name) tfree(s); /*DG avoid memoy leak */ - if (dbs) { - for (td = dbs; td->db_next; td = td->db_next) - ; - td->db_next = d; - } else { + if (last) + last->db_next = d; + else ft_curckt->ci_dbs = dbs = d; - } + + last = d; wl = wl->wl_next; }