diff mbox series

[01/12] qga/channel-posix: Plug memory leak in ga_channel_write_all()

Message ID 20200814160241.7915-2-pannengyuan@huawei.com (mailing list archive)
State New, archived
Headers show
Series fix some error memleaks | expand

Commit Message

Pan Nengyuan Aug. 14, 2020, 4:02 p.m. UTC
Missing g_error_free on error path in ga_channel_write_all(). Fix that.

Reported-by: Euler Robot <euler.robot@huawei.com>
Signed-off-by: Pan Nengyuan <pannengyuan@huawei.com>
---
Cc: Michael Roth <mdroth@linux.vnet.ibm.com>
---
 qga/channel-posix.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Li Qiang Aug. 26, 2020, 11:57 a.m. UTC | #1
Pan Nengyuan <pannengyuan@huawei.com> 于2020年8月14日周五 下午6:30写道:
>
> Missing g_error_free on error path in ga_channel_write_all(). Fix that.
>
> Reported-by: Euler Robot <euler.robot@huawei.com>
> Signed-off-by: Pan Nengyuan <pannengyuan@huawei.com>

Reviewed-by: Li Qiang <liq3ea@gmail.com>

> ---
> Cc: Michael Roth <mdroth@linux.vnet.ibm.com>
> ---
>  qga/channel-posix.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/qga/channel-posix.c b/qga/channel-posix.c
> index 8fc205ad21..0b151cb87b 100644
> --- a/qga/channel-posix.c
> +++ b/qga/channel-posix.c
> @@ -249,7 +249,7 @@ GIOStatus ga_channel_write_all(GAChannel *c, const gchar *buf, gsize size)
>              buf += written;
>          } else if (status != G_IO_STATUS_AGAIN) {
>              g_warning("error writing to channel: %s", err->message);
> -            return status;
> +            goto out;
>          }
>      }
>
> @@ -261,6 +261,10 @@ GIOStatus ga_channel_write_all(GAChannel *c, const gchar *buf, gsize size)
>          g_warning("error flushing channel: %s", err->message);
>      }
>
> +out:
> +    if (err) {
> +        g_error_free(err);
> +    }
>      return status;
>  }
>
> --
> 2.18.2
>
>
diff mbox series

Patch

diff --git a/qga/channel-posix.c b/qga/channel-posix.c
index 8fc205ad21..0b151cb87b 100644
--- a/qga/channel-posix.c
+++ b/qga/channel-posix.c
@@ -249,7 +249,7 @@  GIOStatus ga_channel_write_all(GAChannel *c, const gchar *buf, gsize size)
             buf += written;
         } else if (status != G_IO_STATUS_AGAIN) {
             g_warning("error writing to channel: %s", err->message);
-            return status;
+            goto out;
         }
     }
 
@@ -261,6 +261,10 @@  GIOStatus ga_channel_write_all(GAChannel *c, const gchar *buf, gsize size)
         g_warning("error flushing channel: %s", err->message);
     }
 
+out:
+    if (err) {
+        g_error_free(err);
+    }
     return status;
 }