tests: utils: Tolerate NULL actual data in virTestCompareToFile

The function docs state that 'strcontent' may be NULL. This was added in
8b3a0b28ba but that commit neglected to fix rest of the function.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
Peter Krempa 2018-03-27 18:14:12 +02:00
parent 452c2cc7e7
commit dff110d232

View File

@ -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;
}