From 11b7b07f8a15879134a54e73fade98d5e11e04f8 Mon Sep 17 00:00:00 2001 From: "Emilio G. Cota" Date: Mon, 25 Jul 2016 11:03:45 -0400 Subject: qdist: return "(empty)" instead of NULL when printing an empty dist Printf'ing a NULL string is undefined behaviour. Avoid it. Reported-by: Peter Maydell Signed-off-by: Emilio G. Cota Message-Id: <1469459025-23606-4-git-send-email-cota@braap.org> Signed-off-by: Paolo Bonzini --- tests/test-qdist.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/test-qdist.c b/tests/test-qdist.c index 0298986ac9..9541ce31eb 100644 --- a/tests/test-qdist.c +++ b/tests/test-qdist.c @@ -360,10 +360,16 @@ static void test_none(void) g_assert(isnan(qdist_xmax(&dist))); pr = qdist_pr_plain(&dist, 0); - g_assert(pr == NULL); + g_assert_cmpstr(pr, ==, "(empty)"); + g_free(pr); pr = qdist_pr_plain(&dist, 2); - g_assert(pr == NULL); + g_assert_cmpstr(pr, ==, "(empty)"); + g_free(pr); + + pr = qdist_pr(&dist, 0, QDIST_PR_BORDER); + g_assert_cmpstr(pr, ==, "(empty)"); + g_free(pr); qdist_destroy(&dist); } -- cgit v1.2.3