Open mbrubeck opened 7 years ago
How about 'index' larger than 2^31 on 32 bit platforms?
How about 'index' larger than 2^31 on 32 bit platforms?
That would also be bad. Looking closely I don't think it's possible to trigger, because all allocation is done through std::vec::Vec
, which panics if it tries to allocate more than isize::MAX
bytes. Since cap
can never exceed isize::MAX
, and len
can never exceed cap
, the check that index < len
is sufficient.
Vec32
assumes that casting fromu32
tousize
is always lossless, which is not true on 8-bit or 16-bit platforms and could cause undefined behavior there.