Skip to content

Commit ecfca31

Browse files
theanarkhmarco-ippolito
authored andcommitted
os: fix GetInterfaceAddresses memory lieaky
PR-URL: #58940 Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
1 parent 3bc0497 commit ecfca31

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
@@ -192,6 +192,9 @@ static void GetInterfaceAddresses(const FunctionCallbackInfo<Value>& args) {
192192
return args.GetReturnValue().SetUndefined();
193193
}
194194

195+
auto cleanup =
196+
OnScopeLeave([&]() { uv_free_interface_addresses(interfaces, count); });
197+
195198
Local<Value> no_scope_id = Integer::New(isolate, -1);
196199
std::vector<Local<Value>> result;
197200
result.reserve(count * 7);
@@ -243,7 +246,6 @@ static void GetInterfaceAddresses(const FunctionCallbackInfo<Value>& args) {
243246
}
244247
}
245248

246-
uv_free_interface_addresses(interfaces, count);
247249
args.GetReturnValue().Set(Array::New(isolate, result.data(), result.size()));
248250
}
249251

0 commit comments

Comments
 (0)