qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH] target/i386: Fix memory leak in sev_read_file_base64()


From: Peter Maydell
Subject: Re: [PATCH] target/i386: Fix memory leak in sev_read_file_base64()
Date: Mon, 13 Sep 2021 13:33:35 +0100

Ping?

thanks
-- PMM

On Fri, 20 Aug 2021 at 17:56, Peter Maydell <peter.maydell@linaro.org> wrote:
>
> In sev_read_file_base64() we call g_file_get_contents(), which
> allocates memory for the file contents.  We then base64-decode the
> contents (which allocates another buffer for the decoded data), but
> forgot to free the memory for the original file data.
>
> Use g_autofree to ensure that the file data is freed.
>
> Fixes: Coverity CID 1459997
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> Tested with 'make/make check' only...
>
>  target/i386/sev.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/target/i386/sev.c b/target/i386/sev.c
> index 83df8c09f6a..1e7833da1ab 100644
> --- a/target/i386/sev.c
> +++ b/target/i386/sev.c
> @@ -565,7 +565,7 @@ static int
>  sev_read_file_base64(const char *filename, guchar **data, gsize *len)
>  {
>      gsize sz;
> -    gchar *base64;
> +    g_autofree gchar *base64 = NULL;
>      GError *error = NULL;
>
>      if (!g_file_get_contents(filename, &base64, &sz, &error)) {
> --
> 2.20.1
>



reply via email to

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