Avoid array underflow (& thus SEGV) when no data points are set (workaround segv in bz 208185)

This commit is contained in:
Daniel P. Berrange
2006-09-27 17:00:28 -04:00
parent 1488d0c7ae
commit 17b236aba4
2 changed files with 18 additions and 14 deletions

View File

@@ -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);

View File

@@ -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: */