Skip to content

Commit

Permalink
version this
Browse files Browse the repository at this point in the history
  • Loading branch information
cirospaciari committed Apr 19, 2024
1 parent 4fdb9f2 commit 5ef62e0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/bun.js/api/bun/socket.zig
Original file line number Diff line number Diff line change
Expand Up @@ -823,12 +823,13 @@ pub const Listener = struct {
global.throwInvalidArguments("hostname pattern expects a string", .{});
return .zero;
}
const host_str = hostname.toSliceZ(
const host_str = hostname.toSlice(
global,
bun.default_allocator,
);
defer host_str.deinit();
const server_name = host_str.sliceZ();
const server_name = bun.default_allocator.dupeZ(u8, host_str.slice()) catch bun.outOfMemory();
defer bun.default_allocator.free(server_name);
if (server_name.len == 0) {
global.throwInvalidArguments("hostname pattern cannot be empty", .{});
return .zero;
Expand Down
4 changes: 2 additions & 2 deletions src/bun.js/bindings/bindings.zig
Original file line number Diff line number Diff line change
Expand Up @@ -804,8 +804,8 @@ pub const ZigString = extern struct {
pub fn toSliceZ(this: ZigString, allocator: std.mem.Allocator) Slice {
if (this.len == 0)
return Slice.empty;
// if is 16 bit or dont has a null terminator
if (is16Bit(&this) or this._unsafe_ptr_do_not_use[this.len] != 0) {

if (is16Bit(&this)) {
const buffer = this.toOwnedSliceZ(allocator) catch unreachable;
return Slice{
.ptr = buffer.ptr,
Expand Down

0 comments on commit 5ef62e0

Please sign in to comment.