diff --git a/assembly/buffer/index.ts b/assembly/buffer/index.ts index c73f012..769dd8a 100644 --- a/assembly/buffer/index.ts +++ b/assembly/buffer/index.ts @@ -24,18 +24,18 @@ export class Buffer extends Uint8Array { } readUInt8(offset: i32 = 0): u8 { - if(offset > this.dataLength) throw new RangeError(E_INDEXOUTOFRANGE); + if(offset >= this.dataLength) throw new RangeError(E_INDEXOUTOFRANGE); return load(this.dataStart + usize(offset)); } writeUInt8(value: u8, offset: i32 = 0): i32 { - if(offset > this.dataLength) throw new RangeError(E_INDEXOUTOFRANGE); + if(offset >= this.dataLength) throw new RangeError(E_INDEXOUTOFRANGE); store(this.dataStart + offset, value); return offset + 1; } writeInt8(value: i8, offset: i32 = 0): i32 { - if(offset > this.dataLength) throw new RangeError(E_INDEXOUTOFRANGE); + if(offset >= this.dataLength) throw new RangeError(E_INDEXOUTOFRANGE); store(this.dataStart + offset, value); return offset + 1; }