-
Notifications
You must be signed in to change notification settings - Fork 784
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
Fix undefined behavor in GenericStringArray::from_iter_values #1145
Conversation
38a0af9
to
db22383
Compare
I need to port my tests for this but I think the code is fine. I ran out of time today to keep working on this |
Codecov Report
@@ Coverage Diff @@
## master #1145 +/- ##
=======================================
Coverage 82.55% 82.56%
=======================================
Files 169 169
Lines 50456 50497 +41
=======================================
+ Hits 41655 41693 +38
- Misses 8801 8804 +3
Continue to review full report at Codecov.
|
arrow/src/array/array_string.rs
Outdated
|
||
// iterator size hint may not be correct so compute the actual number of offsets | ||
let actual_len = match offsets.len() { | ||
0 => 0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We always push at least one offset (zero), so this match should not be needed. Looks good otherwise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @jhorstmann -- I'll change this to assert len > 0 and try and polish up this PR with tests tomorrow
@@ -187,8 +187,13 @@ impl<OffsetSize: StringOffsetSizeTrait> GenericStringArray<OffsetSize> { | |||
offsets.push(length_so_far); | |||
values.extend_from_slice(s.as_bytes()); | |||
} | |||
|
|||
// iterator size hint may not be correct so compute the actual number of offsets | |||
assert!(!offsets.is_empty()); // wrote at least one |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here is the fix -- the rest of the PR is tests
Which issue does this PR close?
Closes #1144
Rationale for this change
If an iterator produces more values than its declared upper bound, it can result in undefined behavior
What changes are included in this PR?
Fix the bug by using the correct length