From 17b236aba4fa35f3f6b121bf8ff32216f4904d4a Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Wed, 27 Sep 2006 17:00:28 -0400 Subject: [PATCH] Avoid array underflow (& thus SEGV) when no data points are set (workaround segv in bz 208185) --- src/graphWidgets/cellrenderersparkline.c | 16 +++++++++------- src/graphWidgets/sparkline.c | 16 +++++++++------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/graphWidgets/cellrenderersparkline.c b/src/graphWidgets/cellrenderersparkline.c index 981718d42..d0932a0ba 100644 --- a/src/graphWidgets/cellrenderersparkline.c +++ b/src/graphWidgets/cellrenderersparkline.c @@ -301,13 +301,15 @@ gtk_cell_renderer_sparkline_render (GtkCellRenderer *cell, cairo_move_to (cr, cx, cy); } } - if (priv->filled) { - double baseline_y = cell_area->height + cell_area->y; - cairo_line_to (cr, points[data->n_values-1].x, baseline_y); - cairo_line_to (cr, 0, baseline_y); - cairo_fill (cr); - } else { - cairo_stroke (cr); + if (data->n_values) { + if (priv->filled) { + double baseline_y = cell_area->height + cell_area->y; + cairo_line_to (cr, points[data->n_values-1].x, baseline_y); + cairo_line_to (cr, 0, baseline_y); + cairo_fill (cr); + } else { + cairo_stroke (cr); + } } /* Stop clipping: */ cairo_restore (cr); diff --git a/src/graphWidgets/sparkline.c b/src/graphWidgets/sparkline.c index b92b025a4..b6f1695ad 100644 --- a/src/graphWidgets/sparkline.c +++ b/src/graphWidgets/sparkline.c @@ -286,13 +286,15 @@ gtk_sparkline_expose (GtkWidget *widget, cairo_move_to (cr, cx, cy); } } - if (priv->filled) { - double baseline_y = cell_area->height + cell_area->y; - cairo_line_to (cr, cell_area->x + cell_area->width, baseline_y); - cairo_line_to (cr, 0, baseline_y); - cairo_fill (cr); - } else { - cairo_stroke (cr); + if (data->n_values) { + if (priv->filled) { + double baseline_y = cell_area->height + cell_area->y; + cairo_line_to (cr, cell_area->x + cell_area->width, baseline_y); + cairo_line_to (cr, 0, baseline_y); + cairo_fill (cr); + } else { + cairo_stroke (cr); + } } /* Stop clipping: */