From: Jesse Larrew Date: Mon, 29 Apr 2013 15:52:52 +0000 (-0500) Subject: libqtest: only call fclose() on open files X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=beb54a87ba74dfac00906b4c876945c6602cd293;p=qemu.git libqtest: only call fclose() on open files libqtest.c can segfault when calling fclose() if the pidfile wasn't opened successfully. This patch fixes the issue. Signed-off-by: Jesse Larrew Reviewed-by: Anthony Liguori Message-id: 1367250772-17928-1-git-send-email-jlarrew@linux.vnet.ibm.com Signed-off-by: Anthony Liguori --- diff --git a/tests/libqtest.c b/tests/libqtest.c index 884f959992..879ffe91dc 100644 --- a/tests/libqtest.c +++ b/tests/libqtest.c @@ -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; }