diff --git a/src/frontend/postcoms.c b/src/frontend/postcoms.c index 2180d9d8f..dbd275e3d 100644 --- a/src/frontend/postcoms.c +++ b/src/frontend/postcoms.c @@ -434,11 +434,13 @@ com_write(wordlist *wl) */ for (d = vecs; d; d = d->v_link2) { if (d->v_plot == tpl) { + char *basename = vec_basename(d); vv = vec_copy(d); /* Note that since we are building a new plot * we don't want to vec_new this one... */ - vv->v_name = vec_basename(vv); + tfree(vv->v_name); + vv->v_name = basename; if (end) end->v_next = vv; @@ -491,6 +493,13 @@ com_write(wordlist *wl) else raw_write(file, &newplot, appendwrite, TRUE); + for (vv = newplot.pl_dvecs; vv;) { + struct dvec *next_vv = vv->v_next; + vv->v_plot = NULL; + vec_free(vv); + vv = next_vv; + } + /* Now throw out the vectors we have written already... */ for (d = vecs, lv = NULL; d; d = d->v_link2) if (d->v_plot == tpl) { @@ -589,11 +598,13 @@ com_write_sparam(wordlist *wl) */ for (d = vecs; d; d = d->v_link2) { if (d->v_plot == tpl) { + char *basename = vec_basename(d); vv = vec_copy(d); /* Note that since we are building a new plot * we don't want to vec_new this one... */ - vv->v_name = vec_basename(vv); + tfree(vv->v_name); + vv->v_name = basename; if (end) end->v_next = vv; @@ -642,6 +653,13 @@ com_write_sparam(wordlist *wl) spar_write(file, &newplot, Rbaseval); + for (vv = newplot.pl_dvecs; vv;) { + struct dvec *next_vv = vv->v_next; + vv->v_plot = NULL; + vec_free(vv); + vv = next_vv; + } + /* Now throw out the vectors we have written already... */ for (d = vecs, lv = NULL; d; d = d->v_link2) if (d->v_plot == tpl) {