From b012c3470bd5706af4b9733573be53a54d73d2fe Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Wed, 14 Dec 2022 15:11:10 +0000 Subject: [PATCH] gtestutils: Check for failure to setenv() and return This is very unlikely to happen, but it makes Coverity happier. Signed-off-by: Philip Withnall Coverity CID: #1474388 --- glib/gtestutils.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/glib/gtestutils.c b/glib/gtestutils.c index b2506fa00..709c229ca 100644 --- a/glib/gtestutils.c +++ b/glib/gtestutils.c @@ -1684,7 +1684,12 @@ void g_free (tmpl); /* Propagate the temporary directory to subprocesses. */ - g_setenv ("G_TEST_TMPDIR", test_isolate_dirs_tmpdir, TRUE); + if (!g_setenv ("G_TEST_TMPDIR", test_isolate_dirs_tmpdir, TRUE)) + { + g_printerr ("%s: Failed to set environment variable ‘%s’\n", + (*argv)[0], "G_TEST_TMPDIR"); + exit (1); + } /* And clear the traditional environment variables so subprocesses * spawned by the code under test can’t trash anything. If a test @@ -1710,7 +1715,14 @@ void gsize i; for (i = 0; i < G_N_ELEMENTS (overridden_environment_variables); i++) - g_setenv (overridden_environment_variables[i], "/dev/null", TRUE); + { + if (!g_setenv (overridden_environment_variables[i], "/dev/null", TRUE)) + { + g_printerr ("%s: Failed to set environment variable ‘%s’\n", + (*argv)[0], overridden_environment_variables[i]); + exit (1); + } + } } }