From 53eb338048583a338e7c01d2b351f1c679db3e15 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Fri, 1 Sep 2023 02:23:54 -0700 Subject: [PATCH] Update dns_resolver.zig --- src/bun.js/api/bun/dns_resolver.zig | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/bun.js/api/bun/dns_resolver.zig b/src/bun.js/api/bun/dns_resolver.zig index 595313c991..b75c0161f3 100644 --- a/src/bun.js/api/bun/dns_resolver.zig +++ b/src/bun.js/api/bun/dns_resolver.zig @@ -1370,8 +1370,12 @@ pub const DNSResolver = struct { var pending: ?*CAresLookup(cares_type, lookup_name) = key.lookup.head.next; var prev_global = key.lookup.head.globalThis; + + // The callback need not and should not attempt to free the memory + // pointed to by hostent; the ares library will free it when the + // callback returns. var array = addr.toJSReponse(this.vm.allocator, prev_global, lookup_name); - defer addr.deinit(); + array.ensureStillAlive(); key.lookup.head.onComplete(array); bun.default_allocator.destroy(key.lookup);