aseyboldt / fastq-rs

MIT License
47 stars 12 forks source link

buffer clean panics #2

Closed veldsla closed 7 years ago

veldsla commented 7 years ago

The Buffer clean function doesn't consider the case that when buffer.start < 16 the alignment causes new_end to be larger than old_end. This causes an underflow in https://github.com/aseyboldt/fastq-rs/blob/master/src/buffer.rs#L72 which happened to me when I was parsing a gzipped fastq file.

If you want to align you could change the result into an isize or not move the data when buffer.start is less than 16. Or since the result is never used you could skip it entirely.

aseyboldt commented 7 years ago

You are right, thank you. I removed the return value in Buffer.clean. It was meant as a way to detect if the buffer is too small, but it turned out I didn't need it and forgot to remove it.