[PATCH v2 5/6] qga: Fix a memory leak

Philippe Mathieu-Daudé posted 6 patches 5 years, 8 months ago
Maintainers: Stefan Hajnoczi <stefanha@redhat.com>, Kevin Wolf <kwolf@redhat.com>, Stefan Weil <sw@weilnetz.de>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, Michael Roth <mdroth@linux.vnet.ibm.com>
There is a newer version of this series
[PATCH v2 5/6] qga: Fix a memory leak
Posted by Philippe Mathieu-Daudé 5 years, 8 months ago
The string returned by g_win32_error_message() has to be
deallocated with g_free().

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 qga/channel-win32.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/qga/channel-win32.c b/qga/channel-win32.c
index c86f4388db..774205e017 100644
--- a/qga/channel-win32.c
+++ b/qga/channel-win32.c
@@ -302,8 +302,8 @@ static gboolean ga_channel_open(GAChannel *c, GAChannelMethod method,
                            OPEN_EXISTING,
                            FILE_FLAG_NO_BUFFERING | FILE_FLAG_OVERLAPPED, NULL);
     if (c->handle == INVALID_HANDLE_VALUE) {
-        g_critical("error opening path %s: %s", newpath,
-                   g_win32_error_message(GetLastError()));
+        g_autofree gchar *emsg = g_win32_error_message(GetLastError());
+        g_critical("error opening path %s: %s", newpath, emsg);
         return false;
     }
 
-- 
2.21.1


Re: [PATCH v2 5/6] qga: Fix a memory leak
Posted by Marc-André Lureau 5 years, 8 months ago
On Thu, Feb 27, 2020 at 5:32 PM Philippe Mathieu-Daudé
<philmd@redhat.com> wrote:
>
> The string returned by g_win32_error_message() has to be
> deallocated with g_free().
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>


> ---
>  qga/channel-win32.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/qga/channel-win32.c b/qga/channel-win32.c
> index c86f4388db..774205e017 100644
> --- a/qga/channel-win32.c
> +++ b/qga/channel-win32.c
> @@ -302,8 +302,8 @@ static gboolean ga_channel_open(GAChannel *c, GAChannelMethod method,
>                             OPEN_EXISTING,
>                             FILE_FLAG_NO_BUFFERING | FILE_FLAG_OVERLAPPED, NULL);
>      if (c->handle == INVALID_HANDLE_VALUE) {
> -        g_critical("error opening path %s: %s", newpath,
> -                   g_win32_error_message(GetLastError()));
> +        g_autofree gchar *emsg = g_win32_error_message(GetLastError());
> +        g_critical("error opening path %s: %s", newpath, emsg);
>          return false;
>      }
>
> --
> 2.21.1
>