From 216cec1d90912e1bbd1ed3d5a8890d048ce5d69c Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Tue, 14 Oct 2014 10:53:46 +0000 Subject: prevent buffer overrun --- Sgraph.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'Sgraph.c') diff --git a/Sgraph.c b/Sgraph.c index 357e021..cbcabf3 100644 --- a/Sgraph.c +++ b/Sgraph.c @@ -186,7 +186,7 @@ static void Redisplay(Widget w, XEvent *event, Region r) { SgraphWidget sw = (SgraphWidget)w; - Dimension i, x, y; + Dimension i, x, y, width; XdbeSwapInfo swap; if (!XtIsRealized(w)) @@ -196,7 +196,11 @@ Redisplay(Widget w, XEvent *event, Region r) Trace(w); #endif - for (i = 0; i < sw->core.width - 1; i++) { + width = sw->core.width; + if (width > sw->sgraph.size) + width = sw->sgraph.size; + + for (i = 0; i < width - 1; i++) { y = sw->sgraph.values[i]; x = sw->sgraph.mirror ? sw->core.width - i : i; -- cgit v1.2.3