[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] savevm: Fix potential memory leak
From: |
Stefan Weil |
Subject: |
Re: [Qemu-devel] [PATCH] savevm: Fix potential memory leak |
Date: |
Tue, 02 Jul 2013 22:33:28 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130623 Thunderbird/17.0.7 |
Am 16.06.2013 13:33, schrieb Stefan Weil:
> The leak was reported by cppcheck. Fix it by moving the g_malloc0 after
> the argument validity check.
>
> Signed-off-by: Stefan Weil <address@hidden>
> ---
> savevm.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/savevm.c b/savevm.c
> index 2ce439f..b883714 100644
> --- a/savevm.c
> +++ b/savevm.c
> @@ -479,7 +479,7 @@ static const QEMUFileOps socket_write_ops = {
>
> QEMUFile *qemu_fopen_socket(int fd, const char *mode)
> {
> - QEMUFileSocket *s = g_malloc0(sizeof(QEMUFileSocket));
> + QEMUFileSocket *s;
>
> if (mode == NULL ||
> (mode[0] != 'r' && mode[0] != 'w') ||
> @@ -488,6 +488,7 @@ QEMUFile *qemu_fopen_socket(int fd, const char *mode)
> return NULL;
> }
>
> + s = g_malloc0(sizeof(QEMUFileSocket));
> s->fd = fd;
> if (mode[0] == 'w') {
> qemu_set_block(s->fd);
Ping?
- Re: [Qemu-devel] [PATCH] savevm: Fix potential memory leak,
Stefan Weil <=