From: Peter Krempa Date: Tue, 27 Mar 2018 16:14:12 +0000 (+0200) Subject: tests: utils: Tolerate NULL actual data in virTestCompareToFile X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=dff110d232ff6da536350a0d4412be7f85fbbff0;p=libvirt.git tests: utils: Tolerate NULL actual data in virTestCompareToFile The function docs state that 'strcontent' may be NULL. This was added in 8b3a0b28ba2 but that commit neglected to fix rest of the function. Signed-off-by: Peter Krempa --- diff --git a/tests/testutils.c b/tests/testutils.c index 040ef1d2f7..4bd1b63755 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -800,8 +800,8 @@ virTestCompareToFile(const char *strcontent, if (filecontentLen > 0 && filecontent[filecontentLen - 1] == '\n' && - strcontent[strlen(strcontent) - 1] != '\n') { - if (virAsprintf(&fixedcontent, "%s\n", strcontent) < 0) + cmpcontent[strlen(cmpcontent) - 1] != '\n') { + if (virAsprintf(&fixedcontent, "%s\n", cmpcontent) < 0) goto failure; cmpcontent = fixedcontent; }