bug fix, avoid segfault when the refered plot is still empty

This commit is contained in:
rlar 2012-09-27 19:29:51 +02:00
parent 986f9b7535
commit 0280a49b69
1 changed files with 8 additions and 6 deletions

View File

@ -784,7 +784,6 @@ void
vec_free_x(struct dvec *v)
{
struct plot *pl;
struct dvec *lv;
if ((v == NULL) || (v->v_name == NULL))
return;
@ -795,14 +794,17 @@ vec_free_x(struct dvec *v)
if (pl->pl_dvecs == v) {
pl->pl_dvecs = v->v_next;
} else {
for (lv = pl->pl_dvecs; lv->v_next; lv = lv->v_next)
if (lv->v_next == v)
break;
if (lv->v_next == NULL)
struct dvec *lv = pl->pl_dvecs;
if (lv)
for (; lv->v_next; lv = lv->v_next)
if (lv->v_next == v)
break;
if (lv && lv->v_next)
lv->v_next = v->v_next;
else
fprintf(cp_err,
"vec_free: Internal Error: %s not in plot\n",
v->v_name);
lv->v_next = v->v_next;
}
if (pl->pl_scale == v) {
if (pl->pl_dvecs)