mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-27 22:46:15 +01:00
tests: Fix leak of dlopened module in pollable test
Coverity CID: #1446243 Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
This commit is contained in:
parent
dc1f133c88
commit
57a5ed3d08
@ -187,25 +187,28 @@ test_pollable_unix_pty (void)
|
|||||||
{
|
{
|
||||||
int (*openpty_impl) (int *, int *, char *, void *, void *);
|
int (*openpty_impl) (int *, int *, char *, void *, void *);
|
||||||
int a, b, status;
|
int a, b, status;
|
||||||
|
#ifdef __linux__
|
||||||
|
void *handle;
|
||||||
|
#endif
|
||||||
|
|
||||||
g_test_summary ("Test that PTYs are considered pollable");
|
g_test_summary ("Test that PTYs are considered pollable");
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
dlopen ("libutil.so", RTLD_GLOBAL | RTLD_LAZY);
|
handle = dlopen ("libutil.so", RTLD_GLOBAL | RTLD_LAZY);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
openpty_impl = dlsym (RTLD_DEFAULT, "openpty");
|
openpty_impl = dlsym (RTLD_DEFAULT, "openpty");
|
||||||
if (openpty_impl == NULL)
|
if (openpty_impl == NULL)
|
||||||
{
|
{
|
||||||
g_test_skip ("System does not support openpty()");
|
g_test_skip ("System does not support openpty()");
|
||||||
return;
|
goto close_libutil;
|
||||||
}
|
}
|
||||||
|
|
||||||
status = openpty_impl (&a, &b, NULL, NULL, NULL);
|
status = openpty_impl (&a, &b, NULL, NULL, NULL);
|
||||||
if (status == -1)
|
if (status == -1)
|
||||||
{
|
{
|
||||||
g_test_skip ("Unable to open PTY");
|
g_test_skip ("Unable to open PTY");
|
||||||
return;
|
goto close_libutil;
|
||||||
}
|
}
|
||||||
|
|
||||||
in = G_POLLABLE_INPUT_STREAM (g_unix_input_stream_new (a, TRUE));
|
in = G_POLLABLE_INPUT_STREAM (g_unix_input_stream_new (a, TRUE));
|
||||||
@ -218,6 +221,11 @@ test_pollable_unix_pty (void)
|
|||||||
|
|
||||||
close (a);
|
close (a);
|
||||||
close (b);
|
close (b);
|
||||||
|
|
||||||
|
close_libutil:
|
||||||
|
#ifdef __linux__
|
||||||
|
dlclose (handle);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
Reference in New Issue
Block a user