diff options
author | 2013-11-03 11:44:45 +0100 | |
---|---|---|
committer | 2013-11-03 11:44:45 +0100 | |
commit | 5d6556e72378fd85af8486eff0777bc320eaaa72 (patch) | |
tree | 2aabe8986e97e79342c99b89c35ffe01250d08cb /plugins | |
parent | 0869004d5d23c2e6dc2e023387dedb959fd3cfc7 (diff) |
gtkui: fixed spectrum render mem corruption
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/gtkui/widgets.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/plugins/gtkui/widgets.c b/plugins/gtkui/widgets.c index 46d96f7a..b8b529f2 100644 --- a/plugins/gtkui/widgets.c +++ b/plugins/gtkui/widgets.c @@ -2736,26 +2736,24 @@ spectrum_draw (GtkWidget *widget, cairo_t *cr, gpointer user_data) { int stride = cairo_image_surface_get_stride (w->surf); memset (data, 0, a.height * stride); + int barw = width / bands; for (gint i = 0; i <= bands; i++) { - int x = ((width / bands) * i) + 2; + int x = barw * i; int y = a.height - w->bars[i] * base_s; if (y < 0) { y = 0; } - _draw_bar (data, stride, x+1, y, (width / bands) - 1, a.height-y, 0xff007fff); - } - for (gint i = 0; i <= bands; i++) - { - int x = ((width / bands) * i) + 2; - int y = a.height - w->peaks[i] * base_s; - if (y < 0) { - y = 0; + int bw = barw-1; + if (x + bw >= a.width) { + bw = a.width-x-1; } + _draw_bar (data, stride, x+1, y, bw, a.height-y, 0xff007fff); + y = a.height - w->peaks[i] * base_s; if (y < a.height-1) { - _draw_bar (data, stride, x + 1, y, (width / bands) - 1, 1, 0xffffffff); + _draw_bar (data, stride, x + 1, y, bw, 1, 0xffffffff); } - } + } cairo_surface_mark_dirty (w->surf); cairo_save (cr); cairo_set_source_surface (cr, w->surf, 0, 0); |