From 64b43b0c68d04f4104fa669f6398caab24002dcd Mon Sep 17 00:00:00 2001 From: rlar Date: Sat, 26 Dec 2015 19:44:41 +0100 Subject: [PATCH] plotting/plotit.c, xtend(), #4/7 support vector of zero length --- src/frontend/plotting/plotit.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/frontend/plotting/plotit.c b/src/frontend/plotting/plotit.c index 06e588a1d..7b6547b08 100644 --- a/src/frontend/plotting/plotit.c +++ b/src/frontend/plotting/plotit.c @@ -97,21 +97,25 @@ xtend(struct dvec *v, int length) } if (isreal(v)) { + double d = NAN; od = v->v_realdata; v->v_realdata = TMALLOC(double, length); for (i = 0; i < v->v_length; i++) v->v_realdata[i] = od[i]; - d = od[i - 1]; + if (i > 0) + d = od[i - 1]; tfree(od); while (i < length) v->v_realdata[i++] = d; } else { + ngcomplex_t c = {NAN, NAN}; oc = v->v_compdata; v->v_compdata = TMALLOC(ngcomplex_t, length); for (i = 0; i < v->v_length; i++) { v->v_compdata[i] = oc[i]; } - c = oc[i - 1]; + if (i > 0) + c = oc[i - 1]; tfree(oc); while (i < length) v->v_compdata[i++] = c;