From 44d0db011d9ff54cc63564af9d8039c89e830281 Mon Sep 17 00:00:00 2001 From: John Ferlan Date: Mon, 17 Dec 2018 07:02:26 -0500 Subject: [PATCH] tests: Fix possible NULL derefs in virErrorTestMsgs Add guards to avoid calling strchr when @err_noinfo == NULL or calling virErrorTestMsgFormatInfoOne when @err_info == NULL as both would fail with a NULL deref. Signed-off-by: John Ferlan ACKed-by: Peter Krempa --- tests/virerrortest.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/virerrortest.c b/tests/virerrortest.c index eebf259343..b49d1a9135 100644 --- a/tests/virerrortest.c +++ b/tests/virerrortest.c @@ -74,13 +74,13 @@ virErrorTestMsgs(const void *opaque ATTRIBUTE_UNUSED) ret = -1; } - if (strchr(err_noinfo, '%')) { + if (err_noinfo && strchr(err_noinfo, '%')) { VIR_TEST_VERBOSE("\nerror message id %zu contains formatting characters: '%s'\n", i, err_noinfo); ret = -1; } - if (virErrorTestMsgFormatInfoOne(err_info) < 0) + if (err_info && virErrorTestMsgFormatInfoOne(err_info) < 0) ret = -1; } -- GitLab