From patchwork Mon Apr 29 15:52:52 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jesse Larrew X-Patchwork-Id: 240417 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 872C72C00C7 for ; Tue, 30 Apr 2013 02:38:46 +1000 (EST) Received: from localhost ([::1]:34798 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UWr6C-0006zK-Pi for incoming@patchwork.ozlabs.org; Mon, 29 Apr 2013 12:38:44 -0400 Received: from eggs.gnu.org ([208.118.235.92]:51752) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UWr5y-0006zE-JU for qemu-devel@nongnu.org; Mon, 29 Apr 2013 12:38:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UWr5x-00059Y-9B for qemu-devel@nongnu.org; Mon, 29 Apr 2013 12:38:30 -0400 Received: from [32.97.110.55] (port=40050 helo=jlarrew.austin.ibm.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UWr5w-00059J-QX; Mon, 29 Apr 2013 12:38:29 -0400 Received: from jlarrew.austin.ibm.com (localhost [127.0.0.1]) by jlarrew.austin.ibm.com (8.14.5/8.14.5) with ESMTP id r3TFqvJ2017973; Mon, 29 Apr 2013 10:52:57 -0500 Received: (from jlarrew@localhost) by jlarrew.austin.ibm.com (8.14.5/8.14.5/Submit) id r3TFquJT017972; Mon, 29 Apr 2013 10:52:56 -0500 From: Jesse Larrew To: qemu-devel@nongnu.org Date: Mon, 29 Apr 2013 10:52:52 -0500 Message-Id: <1367250772-17928-1-git-send-email-jlarrew@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.11.7 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 32.97.110.55 Cc: qemu-trivial@nongnu.org, aliguori@us.ibm.com, Jesse Larrew Subject: [Qemu-devel] [PATCH] libqtest: only call fclose() on open files X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- tests/libqtest.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/libqtest.c b/tests/libqtest.c index 884f959..879ffe9 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; }