jorgecarleitao / arrow2

Transmute-free Rust library to work with the Arrow format
Apache License 2.0
1.07k stars 223 forks source link

ArrowArrayStreamReader::try_new(): Safeguard against released streams #1501

Closed Qqwy closed 1 year ago

Qqwy commented 1 year ago

Before, passing an already-released stream to ArrowArrayStreamReader::try_new() would result in a call to .get_schema() (and later on when the reader is used possibly to .get_next()), which goes against the spec, as those callbacks should not be called on released streams.

This PR adds an extra check to the start of try_new() to safeguard against already-released streams.

codecov[bot] commented 1 year ago

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.01 :tada:

Comparison is base (99e30d3) 83.58% compared to head (7662b90) 83.60%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1501 +/- ## ========================================== + Coverage 83.58% 83.60% +0.01% ========================================== Files 388 388 Lines 41912 41918 +6 ========================================== + Hits 35034 35045 +11 + Misses 6878 6873 -5 ``` | [Impacted Files](https://app.codecov.io/gh/jorgecarleitao/arrow2/pull/1501?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Jorge+Leitao) | Coverage Δ | | |---|---|---| | [src/ffi/stream.rs](https://app.codecov.io/gh/jorgecarleitao/arrow2/pull/1501?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Jorge+Leitao#diff-c3JjL2ZmaS9zdHJlYW0ucnM=) | `69.07% <100.00%> (+1.27%)` | :arrow_up: | ... and [5 files with indirect coverage changes](https://app.codecov.io/gh/jorgecarleitao/arrow2/pull/1501/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Jorge+Leitao)

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.