Skip to content
Open
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
8 changes: 5 additions & 3 deletions lib/buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ const {
inspect: utilInspect,
} = require('internal/util/inspect');

const assert = require('internal/assert');

const {
codes: {
ERR_BUFFER_OUT_OF_BOUNDS,
Expand Down Expand Up @@ -1302,9 +1304,9 @@ function atob(input) {
throw lazyDOMException(
'The string to be decoded is not correctly encoded.',
'InvalidCharacterError');
case -3: // Possible overflow
// TODO(@anonrig): Throw correct error in here.
throw lazyDOMException('The input causes overflow.', 'InvalidCharacterError');
Comment on lines -1305 to -1307
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An unrecognised error state shouldn't be ignored.

I was thinking something like

    case -3:
      assert.fail('Unrecognized simdutf error');

with internal assert added to the imports in the script header:

@@ -97,10 +97,11 @@ const {
 } = require('internal/util/types');
 const {
   inspect: utilInspect,
 } = require('internal/util/inspect');

+const assert = require('internal/assert');
 const {
   codes: {
     ERR_BUFFER_OUT_OF_BOUNDS,
     ERR_INVALID_ARG_TYPE,
     ERR_INVALID_ARG_VALUE,

case -3:
assert.fail('Unrecognized simdutf error');
break;
default:
return result;
}
Expand Down
Loading