zaeleus / noodles

Bioinformatics I/O libraries in Rust
MIT License
477 stars 53 forks source link

`impl<'a> From<bam::record::Name<'a>> for sam::alignment::record_buf::Name` includes trailing NUL #254

Closed jch-13 closed 4 months ago

jch-13 commented 4 months ago

I noticed that the From conversion from a bam::record::Name to a sam::alignment::record_buf::Name includes the trailing NUL byte (I believe as_ref() might be accidentally called instead of as_bytes() here).

Thank you so much for noodles! :)

zaeleus commented 4 months ago

Good catch, thanks!

Perhaps access to the field should never include the trailing NUL. The AsRef implementation includes the entire raw field in the case a user wants to use it with, e.g., std::ffi::CStr, but noodles neither guarantees there to be a trailing NUL nor has other parts of the API supporting this usage.