From dc3856b51d1805560eaab44c8c17c115d8a8d2d9 Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Mon, 8 May 2017 20:32:15 +0100 Subject: [PATCH] trivial: Fix a tiny memory leak when writing DfuSe images Found using Coverity, many thanks. --- libdfu/dfu-format-dfuse.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libdfu/dfu-format-dfuse.c b/libdfu/dfu-format-dfuse.c index 7306a9ce9..de0cd462d 100644 --- a/libdfu/dfu-format-dfuse.c +++ b/libdfu/dfu-format-dfuse.c @@ -282,7 +282,7 @@ dfu_firmware_to_dfuse (DfuFirmware *firmware, GError **error) guint i; guint32 image_size_total = 0; guint32 offset = sizeof (DfuSePrefix); - guint8 *buf; + g_autofree guint8 *buf = NULL; g_autoptr(GPtrArray) dfuse_images = NULL; /* get all the image data */ @@ -325,7 +325,7 @@ dfu_firmware_to_dfuse (DfuFirmware *firmware, GError **error) } /* return blob */ - return g_bytes_new_take (buf, sizeof (DfuSePrefix) + image_size_total); + return g_bytes_new (buf, sizeof (DfuSePrefix) + image_size_total); } /**