progress: Clamp to avoid unsigned underflow if fetched exceeds total

This commit is contained in:
Sebastian Wick committed 2026-07-27 13:41:00 +00:00
1 parent ab629e27e9
commit 104ed5db5e
1 file changed
+4 -1
+4 -1
View File
@@ -257,7 +257,10 @@ update_status_progress_and_estimating (FlatpakProgress *self)
* delta parts and fallback objects that were already
* available at the start and need not be downloaded.
*/
total = self->total_delta_part_size - self->fetched_delta_part_size + self->total_extra_data_bytes;
/* Clamp to avoid unsigned underflow if fetched exceeds total */
total = self->total_delta_part_size + self->total_extra_data_bytes -
MIN (self->fetched_delta_part_size, self->total_delta_part_size);
formatted_bytes_total = g_format_size_full (total, 0);
g_string_append_printf (buf, _("Downloading: %s/%s"),