mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-26 15:36:14 +01:00
tests: Fix a leak in environment.c with undefined behaviour tests on
`g_environ_setenv()` and `g_environ_unsetenv()` were correctly returning `NULL` when their preconditions failed (as the test is supposed to be exercising). That overwrote the value of `env` without freeing it, resulting in a leak. Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
This commit is contained in:
parent
2249da981a
commit
12a4fcdbed
@ -180,25 +180,31 @@ test_environ_array (void)
|
||||
|
||||
if (g_test_undefined ())
|
||||
{
|
||||
gchar **undefined_env;
|
||||
|
||||
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
|
||||
"*assertion* != NULL*");
|
||||
env = g_environ_setenv (env, NULL, "bar", TRUE);
|
||||
undefined_env = g_environ_setenv (env, NULL, "bar", TRUE);
|
||||
g_test_assert_expected_messages ();
|
||||
g_strfreev (undefined_env);
|
||||
|
||||
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
|
||||
"*assertion* == NULL*");
|
||||
env = g_environ_setenv (env, "foo=fuz", "bar", TRUE);
|
||||
undefined_env = g_environ_setenv (env, "foo=fuz", "bar", TRUE);
|
||||
g_test_assert_expected_messages ();
|
||||
g_strfreev (undefined_env);
|
||||
|
||||
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
|
||||
"*assertion* != NULL*");
|
||||
env = g_environ_setenv (env, "foo", NULL, TRUE);
|
||||
undefined_env = g_environ_setenv (env, "foo", NULL, TRUE);
|
||||
g_test_assert_expected_messages ();
|
||||
g_strfreev (undefined_env);
|
||||
|
||||
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
|
||||
"*assertion* != NULL*");
|
||||
env = g_environ_unsetenv (env, NULL);
|
||||
undefined_env = g_environ_unsetenv (env, NULL);
|
||||
g_test_assert_expected_messages ();
|
||||
g_strfreev (undefined_env);
|
||||
}
|
||||
|
||||
env = g_environ_setenv (env, "foo", "bar", TRUE);
|
||||
|
Loading…
Reference in New Issue
Block a user