mirror of
https://github.com/oven-sh/bun
synced 2026-02-15 05:12:29 +00:00
Replace catch bun.outOfMemory() with safer alternatives (#22141)
Replace `catch bun.outOfMemory()`, which can accidentally catch non-OOM-related errors, with either `bun.handleOom` or a manual `catch |err| switch (err)`. (For internal tracking: fixes STAB-1070) --------- Co-authored-by: Dylan Conway <dylan.conway567@gmail.com>
This commit is contained in:
@@ -22,7 +22,7 @@ const Node = struct {
|
||||
next: ?*Node = null,
|
||||
|
||||
pub fn init(joiner_alloc: Allocator, slice: []const u8, slice_alloc: ?Allocator) *Node {
|
||||
const node = joiner_alloc.create(Node) catch bun.outOfMemory();
|
||||
const node = bun.handleOom(joiner_alloc.create(Node));
|
||||
node.* = .{
|
||||
.slice = slice,
|
||||
.allocator = NullableAllocator.init(slice_alloc),
|
||||
@@ -51,7 +51,7 @@ pub fn pushStatic(this: *StringJoiner, data: []const u8) void {
|
||||
pub fn pushCloned(this: *StringJoiner, data: []const u8) void {
|
||||
if (data.len == 0) return;
|
||||
this.push(
|
||||
this.allocator.dupe(u8, data) catch bun.outOfMemory(),
|
||||
bun.handleOom(this.allocator.dupe(u8, data)),
|
||||
this.allocator,
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user