mirror of
https://github.com/libuv/libuv
synced 2025-03-28 21:13:16 +00:00
doc: free lib pointer before function return (#4720)
In function main, the pointer lib allocated at line 7 is passed as an argument to functions uv_dlopen at line 10, uv_dlerror at lines 11 and 17, and uv_dlsym at line 16, but it is never freed before the function returns at line 24. This results in a memory leak bug.
This commit is contained in:
parent
98a4bab92a
commit
c727be4df9
@ -18,22 +18,21 @@ int main(int argc, char **argv) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
uv_lib_t *lib = (uv_lib_t*) malloc(sizeof(uv_lib_t));
|
||||
uv_lib_t lib;
|
||||
while (--argc) {
|
||||
fprintf(stderr, "Loading %s\n", argv[argc]);
|
||||
if (uv_dlopen(argv[argc], lib)) {
|
||||
fprintf(stderr, "Error: %s\n", uv_dlerror(lib));
|
||||
if (uv_dlopen(argv[argc], &lib)) {
|
||||
fprintf(stderr, "Error: %s\n", uv_dlerror(&lib));
|
||||
continue;
|
||||
}
|
||||
|
||||
init_plugin_function init_plugin;
|
||||
if (uv_dlsym(lib, "initialize", (void **) &init_plugin)) {
|
||||
fprintf(stderr, "dlsym error: %s\n", uv_dlerror(lib));
|
||||
if (uv_dlsym(&lib, "initialize", (void **) &init_plugin)) {
|
||||
fprintf(stderr, "dlsym error: %s\n", uv_dlerror(&lib));
|
||||
continue;
|
||||
}
|
||||
|
||||
init_plugin();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user