Description
Zig Version
0.15.0-dev.1021+43fba5ea8
Steps to Reproduce and Observed Behavior
The new Reader
interface API has methods such as steal()
, restitute()
and rebase()
, which all shift around and play with the buffer. Technically, steal()
and restitute()
only shift the pointer/length around, but rebase()
directly writes to the underlying data, shifting the bytes over.
Simply create a Reader
using the fixed()
API with a const string, read a few bytes, and then use reader.rebase()
.
I only realized this was a problem after encountering #24312 when one of my tests was failing, because I'd passed a const string of an embedded file into a reader on one test, and then did the same on a second test, thus getting unexpected output.
Expected Behavior
Normally, I should have gotten a segfault or some other warning about using const data in the Reader's buffer, but instead I got mangled output that I didn't initially understand.
I'm really not sure how to fix this, outside of removing fixed()
or documenting not to use rebase()
when a Reader
is initialized with it.