Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
_write_bytes_not_aligned(): use
self._io.tell()
in EOF check
In ced78c4, the EOF check used in _write_bytes_not_aligned() was changed to use `self.pos()` instead of `self._io.tell()`, but this turned out to be a mistake. Although it doesn't matter in most cases because it's usually used via the write_bytes() method which aligns the stream to a byte boundary first (and `self.pos()` is equivalent to `self._io.tell()` on a byte boundary), there are few places where it does matter. One place is the write_align_to_byte() method, where the misinterpretation of `self.pos()` would turn into an observable bug if it weren't for the change in 28de847 (which was done for a different reason) - we're testing for this bug since kaitai-io/kaitai_struct_tests@cc36a88. Another place are the actual _write_bytes_not_aligned() calls in the write_bits_int_{be,le}() methods (even though I think in the current implementation the EOF check inside _write_bytes_not_aligned() will not be triggered). All in all, it becomes clear that the EOF check in _write_bytes_not_aligned() must not access `bits_left` - it should work exclusively with the real byte position of the underlying I/O stream.
- Loading branch information