diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2021-08-20 17:56:50 +0100 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2021-09-30 15:30:24 +0200 |
commit | 523a3d9524d5edd49dbec50c634b6e3872ad7d84 (patch) | |
tree | 945754379a3bd477fa54f0346eb0f6be9be0ddf3 /target/i386 | |
parent | 809954efc279deff281ffad3d6a888760ea2b2d9 (diff) | |
download | qemu-523a3d9524d5edd49dbec50c634b6e3872ad7d84.zip qemu-523a3d9524d5edd49dbec50c634b6e3872ad7d84.tar.gz qemu-523a3d9524d5edd49dbec50c634b6e3872ad7d84.tar.bz2 |
target/i386: Fix memory leak in sev_read_file_base64()
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>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20210820165650.2839-1-peter.maydell@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'target/i386')
-rw-r--r-- | target/i386/sev.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/target/i386/sev.c b/target/i386/sev.c index 0b2c8f5..fa72104 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)) { |