Skip to content

Commit a8a1c9a

Browse files
theanarkhaduh95
authored andcommitted
os: fix GetInterfaceAddresses memory lieaky
PR-URL: #58940 Reviewed-By: Juan José Arboleda <[email protected]> Reviewed-By: Chengzhong Wu <[email protected]>
1 parent 3856aee commit a8a1c9a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/node_os.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,9 @@ static void GetInterfaceAddresses(const FunctionCallbackInfo<Value>& args) {
214214
return;
215215
}
216216

217+
auto cleanup =
218+
OnScopeLeave([&]() { uv_free_interface_addresses(interfaces, count); });
219+
217220
Local<Value> no_scope_id = Integer::New(isolate, -1);
218221
LocalVector<Value> result(isolate);
219222
result.reserve(count * 7);
@@ -268,7 +271,6 @@ static void GetInterfaceAddresses(const FunctionCallbackInfo<Value>& args) {
268271
}
269272
}
270273

271-
uv_free_interface_addresses(interfaces, count);
272274
args.GetReturnValue().Set(Array::New(isolate, result.data(), result.size()));
273275
}
274276

0 commit comments

Comments
 (0)