mirror of
https://github.com/oven-sh/bun
synced 2026-02-02 15:08:46 +00:00
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 <claude-bot@bun.sh> Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -420,7 +420,7 @@ pub const String = extern struct {
|
||||
comptime if (@typeInfo(Ctx) != .pointer) @compileError("context must be a pointer");
|
||||
bun.assert(bytes.len > 0);
|
||||
jsc.markBinding(@src());
|
||||
if (bytes.len > max_length()) {
|
||||
if (bytes.len >= max_length()) {
|
||||
if (callback) |cb| {
|
||||
cb(ctx, @ptrCast(@constCast(bytes.ptr)), @truncate(bytes.len));
|
||||
}
|
||||
@@ -460,7 +460,7 @@ pub const String = extern struct {
|
||||
jsc.markBinding(@src());
|
||||
bun.assert(bytes.len > 0);
|
||||
|
||||
if (bytes.len > max_length()) {
|
||||
if (bytes.len >= max_length()) {
|
||||
bun.default_allocator.free(bytes);
|
||||
return dead;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user