Skip to content

Commit

Permalink
test: guard large string decoder allocation
Browse files Browse the repository at this point in the history
Use common.enoughTestMem to avoid "Array buffer allocation failed"
error on low memory devices.

Fixes: #36792

PR-URL: #36795
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Pooja D P <Pooja.D.P@ibm.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
  • Loading branch information
targos committed Jun 11, 2021
1 parent 4686f4f commit c34de75
Showing 1 changed file with 8 additions and 6 deletions.
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

0 comments on commit c34de75

Please sign in to comment.