From 640fa7e17b5f02e29442985cb4b19906fc815600 Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Mon, 7 Feb 2022 15:59:43 +0100 Subject: [PATCH] bug 578 crash when scale is too short Warning message if scale and vector length do not match. Restrict number of points plotted to the smaller of both. --- src/frontend/plotting/plotcurv.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/frontend/plotting/plotcurv.c b/src/frontend/plotting/plotcurv.c index 57b6d3b16..12c440ecd 100644 --- a/src/frontend/plotting/plotcurv.c +++ b/src/frontend/plotting/plotcurv.c @@ -135,7 +135,11 @@ ft_graf(struct dvec *v, struct dvec *xs, bool nostart) Then everything is plotted. */ bool mono = (currentgraph->plottype != PLOT_RETLIN); int dir = 0; - for (i = 0, j = v->v_length; i < j; i++) { + int vlength = v->v_length; + int slength = xs->v_length; + if (slength != vlength) + fprintf(stderr, "Warning: length of vector %s and its scale do not match, plot may be truncated!\n", v->v_name); + for (i = 0, j = min(vlength, slength); i < j; i++) { dx = isreal(xs) ? xs->v_realdata[i] : realpart(xs->v_compdata[i]); dy = isreal(v) ? v->v_realdata[i] :