qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 3/3] savevm: avoid leaking popen(3) file pointer


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH 3/3] savevm: avoid leaking popen(3) file pointer
Date: Thu, 30 May 2013 08:25:09 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130514 Thunderbird/17.0.6

On 05/30/2013 08:14 AM, Stefan Hajnoczi wrote:
> I'm not sure why we check the mode only after invoking popen(3) but we
> need to close the file pointer.
> 
> Spotted by Coverity.
> 
> Cc: Juan Quintela <address@hidden>
> Cc: address@hidden
> Signed-off-by: Stefan Hajnoczi <address@hidden>
> ---
>  savevm.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/savevm.c b/savevm.c
> index 31dcce9..75cc72e 100644
> --- a/savevm.c
> +++ b/savevm.c
> @@ -329,6 +329,7 @@ QEMUFile *qemu_popen_cmd(const char *command, const char 
> *mode)
>  
>      if (mode == NULL || (mode[0] != 'r' && mode[0] != 'w') || mode[1] != 0) {
>          fprintf(stderr, "qemu_popen: Argument validity check failed\n");
> +        fclose(stdio_file);

You MUST use pclose() (not fclose) on any FILE obtained by popen(), to
avoid resource leaks.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]