libsysprof-gtk: skip out of bounds data

This commit is contained in:
Christian Hergert
2023-06-30 16:29:24 -07:00
parent 5493e05100
commit 83c0822990

View File

@ -91,14 +91,18 @@ sysprof_column_layer_snapshot (GtkWidget *widget,
for (guint i = 0; i < n_values; i++) for (guint i = 0; i < n_values; i++)
{ {
int line_height = ceilf (y_values[i] * height); if (x_values[i] < .0)
continue;
if (x_values[i] > 1.)
break;
gtk_snapshot_append_color (snapshot, gtk_snapshot_append_color (snapshot,
color, color,
&GRAPHENE_RECT_INIT (x_values[i] * width, &GRAPHENE_RECT_INIT (x_values[i] * width,
0, 0,
1, 1,
line_height)); ceilf (y_values[i] * height)));
} }
gtk_snapshot_restore (snapshot); gtk_snapshot_restore (snapshot);