mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
os: fix GetInterfaceAddresses memory lieaky
PR-URL: https://github.com/nodejs/node/pull/58940 Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
This commit is contained in:
@@ -214,6 +214,9 @@ static void GetInterfaceAddresses(const FunctionCallbackInfo<Value>& args) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto cleanup =
|
||||
OnScopeLeave([&]() { uv_free_interface_addresses(interfaces, count); });
|
||||
|
||||
Local<Value> no_scope_id = Integer::New(isolate, -1);
|
||||
LocalVector<Value> result(isolate);
|
||||
result.reserve(count * 7);
|
||||
@@ -268,7 +271,6 @@ static void GetInterfaceAddresses(const FunctionCallbackInfo<Value>& args) {
|
||||
}
|
||||
}
|
||||
|
||||
uv_free_interface_addresses(interfaces, count);
|
||||
args.GetReturnValue().Set(Array::New(isolate, result.data(), result.size()));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user