qemu-trivial.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jesse Larrew <jlarrew@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: qemu-trivial@nongnu.org, aliguori@us.ibm.com,
	Jesse Larrew <jlarrew@linux.vnet.ibm.com>
Subject: [Qemu-trivial] [PATCH] libqtest: only call fclose() on open files
Date: Mon, 29 Apr 2013 10:52:52 -0500	[thread overview]
Message-ID: <1367250772-17928-1-git-send-email-jlarrew@linux.vnet.ibm.com> (raw)

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



             reply	other threads:[~2013-04-29 16:38 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-29 15:52 Jesse Larrew [this message]
2013-04-30 14:51 ` [Qemu-trivial] [Qemu-devel] [PATCH] libqtest: only call fclose() on open files Anthony Liguori
2013-05-02 15:55 ` [Qemu-trivial] " Anthony Liguori

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1367250772-17928-1-git-send-email-jlarrew@linux.vnet.ibm.com \
    --to=jlarrew@linux.vnet.ibm.com \
    --cc=aliguori@us.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).