]> xenbits.xensource.com Git - qemu-upstream-4.5-testing.git/commitdiff
libqtest: only call fclose() on open files
authorJesse Larrew <jlarrew@linux.vnet.ibm.com>
Mon, 29 Apr 2013 15:52:52 +0000 (10:52 -0500)
committerAnthony Liguori <aliguori@us.ibm.com>
Tue, 30 Apr 2013 21:04:14 +0000 (16:04 -0500)
libqtest.c can segfault when calling fclose() if the pidfile wasn't
opened successfully. This patch fixes the issue.

Signed-off-by: Jesse Larrew <jlarrew@linux.vnet.ibm.com>
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
Message-id: 1367250772-17928-1-git-send-email-jlarrew@linux.vnet.ibm.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
tests/libqtest.c

index 884f959992e359573282e35e2e77d8efd0aa400b..879ffe91dc26e688c353a446cf87b06c4ba80a23 100644 (file)
@@ -99,8 +99,8 @@ static pid_t qtest_qemu_pid(QTestState *s)
         if (fgets(buffer, sizeof(buffer), f)) {
             pid = atoi(buffer);
         }
+        fclose(f);
     }
-    fclose(f);
     return pid;
 }