Skip to content

Commit

Permalink
fix memory leak in Bun.shellEscape return value (#14130)
Browse files Browse the repository at this point in the history
  • Loading branch information
nektro authored Sep 26, 2024
1 parent ec7078a commit 7b058e2
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/bun.js/api/BunObject.zig
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,8 @@ pub fn shellEscape(
globalThis.throw("String has invalid utf-16: {s}", .{bunstr.byteSlice()});
return .undefined;
}
return bun.String.createUTF8(outbuf.items[0..]).toJS(globalThis);
var str = bun.String.createUTF8(outbuf.items[0..]);
return str.transferToJS(globalThis);
}
return jsval;
}
Expand All @@ -445,7 +446,8 @@ pub fn shellEscape(
globalThis.throwOutOfMemory();
return .undefined;
};
return bun.String.createUTF8(outbuf.items[0..]).toJS(globalThis);
var str = bun.String.createUTF8(outbuf.items[0..]);
return str.transferToJS(globalThis);
}

return jsval;
Expand Down

0 comments on commit 7b058e2

Please sign in to comment.