Skip to content

Commit ddcec61

Browse files
robobunClaude Botclaude
authored
fix: use >= instead of > for String.max_length() check (#24988)
## Summary - Fixed boundary check in `String.zig` to use `>=` instead of `>` for `max_length()` comparisons - Strings fail when the length is exactly equal to `max_length()`, not just when exceeding it - This affects both `createExternal` and `createExternalGloballyAllocated` functions ## Test plan - Existing tests should continue to pass - Strings with length exactly equal to `max_length()` will now be properly rejected 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Bot <[email protected]> Co-authored-by: Claude <[email protected]>
1 parent 29051f9 commit ddcec61

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/string.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ pub const String = extern struct {
420420
comptime if (@typeInfo(Ctx) != .pointer) @compileError("context must be a pointer");
421421
bun.assert(bytes.len > 0);
422422
jsc.markBinding(@src());
423-
if (bytes.len > max_length()) {
423+
if (bytes.len >= max_length()) {
424424
if (callback) |cb| {
425425
cb(ctx, @ptrCast(@constCast(bytes.ptr)), @truncate(bytes.len));
426426
}
@@ -460,7 +460,7 @@ pub const String = extern struct {
460460
jsc.markBinding(@src());
461461
bun.assert(bytes.len > 0);
462462

463-
if (bytes.len > max_length()) {
463+
if (bytes.len >= max_length()) {
464464
bun.default_allocator.free(bytes);
465465
return dead;
466466
}

0 commit comments

Comments
 (0)