Skip to content
Open
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
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');
case -3:
assert.fail('Unrecognized simdutf error');
break;
default:
return result;
}
Expand Down
4 changes: 2 additions & 2 deletions src/node_buffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1341,7 +1341,7 @@ static void Btoa(const FunctionCallbackInfo<Value>& args) {
// In case of error, a negative value is returned:
// * -1 indicates a single character remained,
// * -2 indicates an invalid character,
// * -3 indicates a possible overflow (i.e., more than 2 GB output).
// * -3 indicates an unrecognized simdutf error.
static void Atob(const FunctionCallbackInfo<Value>& args) {
CHECK_EQ(args.Length(), 1);
Environment* env = Environment::GetCurrent(args);
Expand Down Expand Up @@ -1386,7 +1386,7 @@ static void Atob(const FunctionCallbackInfo<Value>& args) {
return args.GetReturnValue().Set(value);
}

// Default value is: "possible overflow"
// Default value is: "unrecognized simdutf error"
int32_t error_code = -3;

if (result.error == simdutf::error_code::INVALID_BASE64_CHARACTER) {
Expand Down
Loading