From b4516b08ca8446d04c2a5601fccd9c9f05b5b131 Mon Sep 17 00:00:00 2001 From: h_vogt Date: Sat, 24 Mar 2012 18:29:36 +0100 Subject: [PATCH] bug fix, iplot(): Buffer overflow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Thanks to Zsolt Makaró for the bug report in Buffer overflow detected - ID: 3510521 http://sourceforge.net/tracker/?func=detail&aid=3510521&group_id=38962&atid=423915 --- src/frontend/plotting/graf.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/frontend/plotting/graf.c b/src/frontend/plotting/graf.c index b20e9790a..9b38a2454 100644 --- a/src/frontend/plotting/graf.c +++ b/src/frontend/plotting/graf.c @@ -654,6 +654,11 @@ iplot(struct plot *pl, int id) if (!yl) yl = v->v_name; } + /* generate a small difference between ymin and ymax + to catch the y=const case */ + if (ylims[0] == ylims[1]) + ylims[1] += 1e-9; + if (ft_grdb) fprintf(cp_err, "iplot: after 5, xlims = %G, %G, ylims = %G, %G\n", @@ -762,6 +767,8 @@ iplot(struct plot *pl, int id) currentgraph->data.ymin) * YFACTOR; /* currentgraph->data.ymin += (dy - currentgraph->data.ymin) * YFACTOR;*/ +/* currentgraph->data.ymin = dy; + currentgraph->data.ymin *= (1 + YFACTOR); */ } if (currentgraph->data.ymax < currentgraph->data.ymin) @@ -779,9 +786,11 @@ iplot(struct plot *pl, int id) /* set the new y hi value */ currentgraph->data.ymax += (currentgraph->data.ymax - - currentgraph->data.ymin) * YFACTOR; + currentgraph->data.ymin) * YFACTOR; /* currentgraph->data.ymax += (dy - currentgraph->data.ymax) * YFACTOR;*/ +/* currentgraph->data.ymax = dy; + currentgraph->data.ymax *= (1 + YFACTOR); */ } } if (changed) {