lib0 icon indicating copy to clipboard operation
lib0 copied to clipboard

Throw when reading past end of array

Open broofa opened this issue 3 years ago • 0 comments

Putting this up as an (untested) fix for #42. This isn't duck-typing but, instead, enforces the known array length. Has the additional benefit of catching other cases where the same infinite-loop problem may occur, such as this:

import { createDecoder, readVarUint } from 'lib0/decoding';
const decoder = createDecoder(new Uint8Array([200, 200, 200, 200]));
readVarUint(decoder);

broofa avatar Aug 20 '22 14:08 broofa