Skip to content

Index recycled string in str_dup() sep branch - #619

Open
sims1253 wants to merge 2 commits into
tidyverse:mainfrom
sims1253:fix/ry-audit-round2
Open

sims1253 wants to merge 2 commits into
tidyverse:mainfrom
sims1253:fix/ry-audit-round2

Conversation

@sims1253

@sims1253 sims1253 commented Sep 9, 2026

Copy link
Copy Markdown

str_dup() in R/dup.R recycles string and times to a common length with vctrs::vec_recycle_common() and stores the result in input. The sep code path loops over seq_along(input$string) but reads elements from the original string, so it walks past the end whenever times is longer than string:

str_dup("na", 0:5, sep = "-")
#> Error: subscript out of bounds

The same call without sep works, because that path hands input$string and input$times to stri_dup(). This PR fixes the index in the sep loop.

str_dup("na", 0:5, sep = "-") now returns "", "na", "na-na", "na-na-na", "na-na-na-na", "na-na-na-na-na".

Found during my most recent ry audit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant