Skip to content

Commit 92ab6e0

Browse files
authored
Avoid integer multiplication when computing width_rule (#295)
1 parent af0c23f commit 92ab6e0

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

NEWS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77

88
## Features / Fixes
99

10+
* Fixed a rare issue where the deprecated `.progress` bar may cause an integer
11+
overflow with extremely long inputs (#288).
12+
1013
* Detangled furrr's documentation from purrr's to avoid some documentation
1114
inheritance issues (#286).
1215

R/progress.R

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ poll_progress <- function(futures, file, n_x) {
2121
width_max <- console_width()
2222
width_usable <- width_max - width_prefix - width_suffix - width_carriage
2323

24-
width_rule <- floor(width_usable * n_ticks / n_x)
24+
# Supposedly someone has seen the multiplication integer overflow for
25+
# extremely long inputs, so we `as.double()` one of the operands, but the
26+
# result after division should still always fit in an integer (#288)
27+
width_rule <- as.integer(floor(width_usable * as.double(n_ticks) / n_x))
2528
width_space <- width_usable - width_rule
2629

2730
space <- paste0(rep(" ", times = width_space), collapse = "")

0 commit comments

Comments
 (0)