Since 1e2ae2e31, changes to use the automagic free logic didn't take
into account that one path uses posix_memalign and the other uses
VIR_ALLOC_N - the former requires using VIR_FREE() and not g_free()
to free the memory.
Found by Coverity.
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
src/util/iohelper.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/src/util/iohelper.c b/src/util/iohelper.c
index 342bae229b..64b7a13f61 100644
--- a/src/util/iohelper.c
+++ b/src/util/iohelper.c
@@ -45,7 +45,11 @@
static int
runIO(const char *path, int fd, int oflags)
{
+#if HAVE_POSIX_MEMALIGN
+ void *base = NULL; /* Location to be freed */
+#else
g_autofree void *base = NULL; /* Location to be freed */
+#endif
char *buf = NULL; /* Aligned location within base */
size_t buflen = 1024*1024;
intptr_t alignMask = 64*1024 - 1;
@@ -168,6 +172,9 @@ runIO(const char *path, int fd, int oflags)
ret = 0;
cleanup:
+#if HAVE_POSIX_MEMALIGN
+ VIR_FREE(base);
+#endif
if (VIR_CLOSE(fd) < 0 &&
ret == 0) {
virReportSystemError(errno, _("Unable to close %s"), path);
--
2.25.4