fs: fix out of bounds error when reading chunks

This commit is contained in:
Abdullah Atta
2024-04-26 13:57:00 +05:00
parent f047552f18
commit 568c88be3e

View File

@@ -71,7 +71,7 @@ export default class FileHandle {
async readChunks(from: number, length: number): Promise<Blob> {
const blobParts: BlobPart[] = [];
for (let i = from; i < from + length; ++i) {
for (let i = from; i < Math.min(from + length, this.file.chunks); ++i) {
const array = await this.readChunk(i);
if (!array) continue;
blobParts.push(array.buffer);