gtestutils: Fix a potential NULL pointer dereference in g_test_log()

Although unlikely, apparently `message` may be `NULL` (the rest of the
code checks for it), so the code to convert newlines to spaces should
probably also check for `NULL`.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Coverity CID: #1504054
This commit is contained in:
Philip Withnall 2023-01-24 11:33:18 +00:00
parent 20c4fcb2a7
commit 2676ef03cc

View File

@ -1214,13 +1214,16 @@ g_test_log (GTestLogType lbit,
if (test_tap_log)
{
char *message = g_strdup (string1);
char *line = message;
while ((line = strchr (line, '\n')))
*(line++) = ' ';
if (message)
message = g_strstrip (message);
{
char *line = message;
while ((line = strchr (line, '\n')))
*(line++) = ' ';
message = g_strstrip (message);
}
if (test_run_name && *test_run_name != '\0')
{