Skip to content

Commit 3b11dbf

Browse files
committed
os: fix GetInterfaceAddresses memory lieaky
1 parent ba8fbf3 commit 3b11dbf

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
@@ -199,6 +199,9 @@ static void GetInterfaceAddresses(const FunctionCallbackInfo<Value>& args) {
199199
return args.GetReturnValue().SetUndefined();
200200
}
201201

202+
auto cleanup =
203+
OnScopeLeave([&]() { uv_free_interface_addresses(interfaces, count); });
204+
202205
Local<Value> no_scope_id = Integer::New(isolate, -1);
203206
LocalVector<Value> result(isolate);
204207
result.reserve(count * 7);
@@ -253,7 +256,6 @@ static void GetInterfaceAddresses(const FunctionCallbackInfo<Value>& args) {
253256
}
254257
}
255258

256-
uv_free_interface_addresses(interfaces, count);
257259
args.GetReturnValue().Set(Array::New(isolate, result.data(), result.size()));
258260
}
259261

0 commit comments

Comments
 (0)