widgets: Use 64bit for HistogramEditor counts

Resolves #13014
In GimpHistogramEditor, pixels and counts are stored
as doubles. We previously converted them into 32bit integers
when displaying the values to the user.

As it is possible for the dimensions of an image to exceed the
limit of a 32bit integer, this could lead to overflow and negative
pixel counts.

This patch switches our display code to use 64bit gsize casts
for conversion to prevent this from happening.
This commit is contained in:
Alx Sa 2026-02-13 06:17:52 +00:00
parent 29f991cbf2
commit 11f131aa1f

View file

@ -798,10 +798,10 @@ gimp_histogram_editor_info_update (GimpHistogramEditor *editor)
view->end));
gtk_label_set_text (GTK_LABEL (editor->labels[LABEL_MEDIAN]), text);
g_snprintf (text, sizeof (text), "%d", (gint) pixels);
g_snprintf (text, sizeof (text), "%" G_GSIZE_FORMAT, (gsize) pixels);
gtk_label_set_text (GTK_LABEL (editor->labels[LABEL_PIXELS]), text);
g_snprintf (text, sizeof (text), "%d", (gint) count);
g_snprintf (text, sizeof (text), "%" G_GSIZE_FORMAT, (gsize) count);
gtk_label_set_text (GTK_LABEL (editor->labels[LABEL_COUNT]), text);
g_snprintf (text, sizeof (text), "%.1f", (pixels > 0 ?