Commit e6c11e0b authored by Aaron Plattner's avatar Aaron Plattner
Browse files

Don't leak the vdpau_wrapper.cfg file pointer



init_config opens vdpau_wrapper.cfg and reads its contents, but never closes it.
This causes a file descriptor leak if libvdpau is unloaded and reloaded.
Signed-off-by: default avatarAaron Plattner <aplattner@nvidia.com>
Reviewed-by: default avatarAndy Ritger <aritger@nvidia.com>
Reviewed-by: default avatarJosep Torra <josep@fluendo.com>
parent 626037b8
...@@ -356,6 +356,8 @@ void init_config(void) ...@@ -356,6 +356,8 @@ void init_config(void)
_disable_flash_pq_bg_color = atoi(param); _disable_flash_pq_bg_color = atoi(param);
} }
} }
fclose(fp);
} }
void init_fixes(void) void init_fixes(void)
......
#include <dirent.h>
#include <dlfcn.h> #include <dlfcn.h>
#include <stdio.h> #include <stdio.h>
#include <vdpau/vdpau.h> #include <vdpau/vdpau.h>
...@@ -8,11 +9,32 @@ ...@@ -8,11 +9,32 @@
#define FAIL 1 #define FAIL 1
#define SKIP 77 #define SKIP 77
static int countOpenFDs(void)
{
DIR *dir = opendir("/proc/self/fd");
struct dirent *ent;
int count = 0;
if (!dir) {
fprintf(stderr, "Couldn't open /proc/self/fd; skipping file descriptor "
"leak test\n");
return 0;
}
while (ent = readdir(dir)) {
count++;
}
closedir(dir);
return count;
}
int main() int main()
{ {
// Work around a bug in libXext: dlclosing it after it has registered the // Work around a bug in libXext: dlclosing it after it has registered the
// Generic Event Extension causes an identical bug to the one this program // Generic Event Extension causes an identical bug to the one this program
// is trying to test for. // is trying to test for.
int nOpenFDs = countOpenFDs();
void *libXext = dlopen("libXext.so.6", RTLD_LAZY); void *libXext = dlopen("libXext.so.6", RTLD_LAZY);
void *libvdpau = dlopen("../src/.libs/libvdpau.so", RTLD_LAZY); void *libvdpau = dlopen("../src/.libs/libvdpau.so", RTLD_LAZY);
Display *dpy = XOpenDisplay(NULL); Display *dpy = XOpenDisplay(NULL);
...@@ -60,5 +82,11 @@ int main() ...@@ -60,5 +82,11 @@ int main()
dlclose(libvdpau); dlclose(libvdpau);
XCloseDisplay(dpy); XCloseDisplay(dpy);
// Make sure no file descriptors were leaked.
if (countOpenFDs() != nOpenFDs) {
fprintf(stderr, "Mismatch in the number of open file descriptors!\n");
return FAIL;
}
return PASS; return PASS;
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment