Skip to content
Merged
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
test: guard large string decoder allocation
Use common.enoughTestMem to avoid "Array buffer allocation failed"
error on low memory devices.

Fixes: #36792

PR-URL: #36795
Reviewed-By: Gireesh Punathil <[email protected]>
Reviewed-By: Pooja D P <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
  • Loading branch information
targos authored and aduh95 committed Jan 5, 2021
commit e5b8c61717cf49ea64adf9029f0dd6fe6ffe7d42
14 changes: 8 additions & 6 deletions test/parallel/test-string-decoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,14 @@ assert.throws(
}
);

assert.throws(
() => new StringDecoder().write(Buffer.alloc(0x1fffffe8 + 1).fill('a')),
{
code: 'ERR_STRING_TOO_LONG',
}
);
if (common.enoughTestMem) {
assert.throws(
() => new StringDecoder().write(Buffer.alloc(0x1fffffe8 + 1).fill('a')),
{
code: 'ERR_STRING_TOO_LONG',
}
);
}

// Test verifies that StringDecoder will correctly decode the given input
// buffer with the given encoding to the expected output. It will attempt all
Expand Down