]> xenbits.xensource.com Git - libvirt.git/commitdiff
tests: utils: Tolerate NULL actual data in virTestCompareToFile
authorPeter Krempa <pkrempa@redhat.com>
Tue, 27 Mar 2018 16:14:12 +0000 (18:14 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 3 Apr 2018 13:48:37 +0000 (15:48 +0200)
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 <pkrempa@redhat.com>
tests/testutils.c

index 040ef1d2f7dec550901709fb4074255ebd5fcea0..4bd1b63755f1e8f26da4887c794a0159aa963e14 100644 (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;
         }