[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] do not check pointers after dereferencing them
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH] do not check pointers after dereferencing them |
Date: |
Fri, 31 May 2013 06:46:21 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130514 Thunderbird/17.0.6 |
On 05/31/2013 06:00 AM, Paolo Bonzini wrote:
> Two instances, both spotted by Coverity. In one, two blocks were
> swapped. In the other, the check is not needed anymore.
>
> Cc: address@hidden
> Cc: address@hidden
> Signed-off-by: Paolo Bonzini <address@hidden>
> ---
> monitor.c | 2 +-
> savevm.c | 10 +++++-----
> 2 files changed, 6 insertions(+), 6 deletions(-)
This version of the savevm.c fix is nicer than Stefan's attempt:
https://lists.gnu.org/archive/html/qemu-devel/2013-05/msg04506.html
Reviewed-by: Eric Blake <address@hidden>
> +++ b/savevm.c
> @@ -322,16 +322,16 @@ QEMUFile *qemu_popen_cmd(const char *command, const
> char *mode)
> FILE *stdio_file;
> QEMUFileStdio *s;
>
> - stdio_file = popen(command, mode);
> - if (stdio_file == NULL) {
> - return NULL;
> - }
> -
> if (mode == NULL || (mode[0] != 'r' && mode[0] != 'w') || mode[1] != 0) {
> fprintf(stderr, "qemu_popen: Argument validity check failed\n");
> return NULL;
> }
>
> + stdio_file = popen(command, mode);
> + if (stdio_file == NULL) {
> + return NULL;
> + }
> +
> s = g_malloc0(sizeof(QEMUFileStdio));
>
> s->stdio_file = stdio_file;
>
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature