On 2/3/23 12:55 AM, blinxen wrote:
> So what your saying is that because we create a memory layout for a
> single u8 value
> and then set it as the pointer for the Vec which we then trick into
> thinking that it has a lot of memory causes UB?
> This would mean that what I wrote into the issue is completely wrong? Is
> that correct?
Right, AFAICT the self.get_unchecked_mut(len) is somewhat ok -- it's at
least a pointer to allocated memory, although creating &mut T to
uninitialized memory (past the end of the proper slice) is not good
either. That should really use pointer add, and I think I'll send a PR
for that.
But the actual crash you're experiencing is while reading the input
slice. The weird 133937 index number is just because there happens to be
mapped memory near that u8 allocation for some distance, then it crashes
on unmapped memory. It's all UB reading after the first byte though.