Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

subset column with numeric value 0 <= j < 1 causes segfault #413

Closed
joshuaulrich opened this issue Jan 31, 2024 · 0 comments
Closed

subset column with numeric value 0 <= j < 1 causes segfault #413

joshuaulrich opened this issue Jan 31, 2024 · 0 comments
Assignees
Labels
Milestone

Comments

@joshuaulrich
Copy link
Owner

Yes this is silly, but it shouldn't crash the R session.

require(xts)
data(sample_matrix)
x <- as.xts(sample_matrix)
x[, 0.1]
@joshuaulrich joshuaulrich self-assigned this Jan 31, 2024
joshuaulrich added a commit that referenced this issue Feb 6, 2024
Convert 'i' to integer in the R code to avoid issues when it's passed
to the C code. I couldn't get this to crash like I could with the code
for 'j', but it caused incorrect results when values in 'i' were set
to zero during conversion to integer.

See #413.
joshuaulrich added a commit that referenced this issue Feb 6, 2024
We need to convert 'i' and 'j' to integer if they're numeric with a
fractional component. This was only being done when 'i' and 'j' were
positive.

Also fix the if-statement. sum() could have returned NA and it's better
to use isTRUE() and any() anyway.

Fixes #415. See #413.
@joshuaulrich joshuaulrich added this to the Next release milestone Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant