Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b196c1d

Browse filesBrowse files
skomskiFishrock123
authored andcommitted
src: fix memory leak in DLOpen
PR-URL: #2375 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
1 parent a3160c0 commit b196c1d
Copy full SHA for b196c1d

File tree

Expand file treeCollapse file tree

1 file changed

+5
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+5
-0
lines changed
Open diff view settings
Collapse file

‎src/node.cc‎

Copy file name to clipboardExpand all lines: src/node.cc
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2124,6 +2124,7 @@ void DLOpen(const FunctionCallbackInfo<Value>& args) {
21242124

21252125
if (is_dlopen_error) {
21262126
Local<String> errmsg = OneByteString(env->isolate(), uv_dlerror(&lib));
2127+
uv_dlclose(&lib);
21272128
#ifdef _WIN32
21282129
// Windows needs to add the filename into the error message
21292130
errmsg = String::Concat(errmsg, args[1]->ToString(env->isolate()));
@@ -2133,10 +2134,12 @@ void DLOpen(const FunctionCallbackInfo<Value>& args) {
21332134
}
21342135

21352136
if (mp == nullptr) {
2137+
uv_dlclose(&lib);
21362138
env->ThrowError("Module did not self-register.");
21372139
return;
21382140
}
21392141
if (mp->nm_version != NODE_MODULE_VERSION) {
2142+
uv_dlclose(&lib);
21402143
char errmsg[1024];
21412144
snprintf(errmsg,
21422145
sizeof(errmsg),
@@ -2146,6 +2149,7 @@ void DLOpen(const FunctionCallbackInfo<Value>& args) {
21462149
return;
21472150
}
21482151
if (mp->nm_flags & NM_F_BUILTIN) {
2152+
uv_dlclose(&lib);
21492153
env->ThrowError("Built-in module self-registered.");
21502154
return;
21512155
}
@@ -2162,6 +2166,7 @@ void DLOpen(const FunctionCallbackInfo<Value>& args) {
21622166
} else if (mp->nm_register_func != nullptr) {
21632167
mp->nm_register_func(exports, module, mp->nm_priv);
21642168
} else {
2169+
uv_dlclose(&lib);
21652170
env->ThrowError("Module has no declared entry point.");
21662171
return;
21672172
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.