Skip to content

Commit

Permalink
fix MAX_STRING_LENGTH constant value (#14196)
Browse files Browse the repository at this point in the history
  • Loading branch information
nektro authored Sep 27, 2024
1 parent 89fc3ef commit 7113206
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/bun.js/modules/NodeBufferModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,15 @@ DEFINE_NATIVE_MODULE(NodeBuffer) {
JSC::jsNumber(MAX_ARRAY_BUFFER_SIZE));

put(JSC::Identifier::fromString(vm, "kStringMaxLength"_s),
JSC::jsNumber(std::numeric_limits<unsigned>().max()));
JSC::jsNumber(WTF::String::MaxLength));

JSC::JSObject *constants = JSC::constructEmptyObject(
lexicalGlobalObject, globalObject->objectPrototype(), 2);
constants->putDirect(vm, JSC::Identifier::fromString(vm, "MAX_LENGTH"_s),
JSC::jsNumber(MAX_ARRAY_BUFFER_SIZE));
constants->putDirect(vm,
JSC::Identifier::fromString(vm, "MAX_STRING_LENGTH"_s),
JSC::jsNumber(std::numeric_limits<unsigned>().max()));
JSC::jsNumber(WTF::String::MaxLength));

put(JSC::Identifier::fromString(vm, "constants"_s), constants);

Expand Down
4 changes: 2 additions & 2 deletions test/js/node/buffer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2003,9 +2003,9 @@ for (let withOverridenBufferWrite of [false, true]) {

it("constants", () => {
expect(BufferModule.constants.MAX_LENGTH).toBe(4294967296);
expect(BufferModule.constants.MAX_STRING_LENGTH).toBe(4294967295);
expect(BufferModule.constants.MAX_STRING_LENGTH).toBe(2147483647);
expect(BufferModule.default.constants.MAX_LENGTH).toBe(4294967296);
expect(BufferModule.default.constants.MAX_STRING_LENGTH).toBe(4294967295);
expect(BufferModule.default.constants.MAX_STRING_LENGTH).toBe(2147483647);
});

it("File", () => {
Expand Down

0 comments on commit 7113206

Please sign in to comment.