Skip to content

Commit 106df6b

Browse files
committed
Fix dangling pointer in ipToBytes
1 parent d1be2b7 commit 106df6b

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/net.zig

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub const IP = union(enum) {
1414
pub fn init(addr: std.net.Address) IP {
1515
return switch (addr.any.family) {
1616
std.posix.AF.INET => .{
17-
.v4 = std.mem.asBytes(&addr.in.sa.addr).*,
17+
.v4 = std.mem.asBytes(&addr.in.sa.addr),
1818
},
1919
std.posix.AF.INET6 => .{
2020
.v6 = addr.in6.sa.addr,
@@ -78,8 +78,7 @@ pub const IP = union(enum) {
7878
pub fn ipToBytes(address: *const std.net.Address) []const u8 {
7979
return switch (address.any.family) {
8080
std.posix.AF.INET => {
81-
const b = std.mem.asBytes(&address.in.sa.addr).*;
82-
return &b;
81+
return std.mem.asBytes(&address.in.sa.addr);
8382
},
8483
std.posix.AF.INET6 => &address.in6.sa.addr,
8584
else => unreachable,

0 commit comments

Comments
 (0)