Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
buffer: remove lines setting indexes to integer value
  • Loading branch information
kylo5aby authored and aduh95 committed May 6, 2024
commit 66c36b4bd6b6f3cffda101d5bfe2c39f9d373a6d
2 changes: 0 additions & 2 deletions lib/internal/blob.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,14 +243,12 @@ class Blob {
} else {
start = MathMin(start, this[kLength]);
}
start |= 0;

if (end < 0) {
end = MathMax(this[kLength] + end, 0);
} else {
end = MathMin(end, this[kLength]);
}
end |= 0;

contentType = `${contentType}`;
if (RegExpPrototypeExec(disallowedTypeCharacters, contentType) !== null) {
Expand Down
21 changes: 21 additions & 0 deletions test/pummel/test-blob-slice-with-large-size.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
'use strict';
const common = require('../common');

// Buffer with size > INT32_MAX
common.skipIf32Bits();

const assert = require('assert');

const size = 2 ** 31;

try {
const buf = Buffer.allocUnsafe(size);
const blob = new Blob([buf]);
const slicedBlob = blob.slice(size - 1, size);
assert.strictEqual(slicedBlob.size, 1);
} catch (e) {
if (e.code !== 'ERR_MEMORY_ALLOCATION_FAILED') {
throw e;
}
common.skip('insufficient space for Buffer.allocUnsafe');
}